Use of fetch javascritp. And receive data with express

1

I have a question. You will see I am sending the data of my form with help of fetch like this:

const formSignin = document.querySelector('#formSignin');
formSignin.addEventListener("submit", event => {
  event.preventDefault();
  const formDataSignin = new FormData(formSignin);

  fetch('/signin', {
      method: 'post',
      body: formDataSignin
    })
    .then(res => res.json())
    .then(data => {
      //Alguna respuesta
    });
});

But once it reaches the server nodejs , it says that the data is undefined.

console.log(req.body.user);

On the other hand, with the Postman tool, I can send them without problem and they are received well.

Someone could have a solution

    
asked by José Llamas 23.01.2018 в 21:28
source

0 answers