Stack Exchange
1 Errors about client-side and server-side
Basically, in my formhandler.js I have edited the code to be
function handleSubmit(event) {
  event.preventDefault();
  // check what text was put into the form field
  let formText = document.getElementById('name').value;
  console.log("::: Form Submitted :::");
  fetch('/sentiment', {
    method: "POST",
    credentials: "same-origin",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text: document.getElementById('name').value })
   })
  .then(res => res.json())
  .then(function(res) {
    document.getElementById('results').innerHTML = res.message;
  });

In the client/index.js , I have
const button = document.querySelector('#submitname');
button.addEventListener('click', handleSubmit);

And my server-side post request looks like:
app.post("/sentiment", (req, res) => {
  console.log('sentiment started');
  textapi.language({
    text: req.body.text,
    mode: tweet,
  }, (error, response) => {
    if (error) {
      console.log('u got errored');
      return;
    }
    res.send(response);
  });
});

However, I am getting an error that says:
formHandler.js:9 POST http://localhost:8080/sentiment 404 (Not Found)

What can I do? My project link is below if you want to check other files. I am using WebPack for build and express as my server.
GitHub Link

Are you actually running your express server or the Webpack dev server? Looks like you should be running npm run build-prod && npm start to build and run the entire app

@Phil , That is what I am doing.

Try removing the app.get('/', ...) route. You shouldn't need it anyway. Have you tried testing the API with Postman or Curl?
