0
votes

I am trying to send data to my Google Cloud server. (login form). I have an error,

[Error: Request failed with status code 404]

I also tried fetch method, but I got a network failed error there.

This is my code:

handleLoginUser(){
const data = new FormData();
  data.append('email', 'aaykgxr@gmail.com');
  data.append('password', '1234567890');

  return axios.post('http://*serverip*/users/login',
    data,
    {
      headers: {
        'Content-Type': 'application/json',
      }
    },
  )
  .then(function (response) {
          console.log(response);
      })
      .catch(function (response) {
          console.log(response);
      });
}

Thanks for your help.

2
I guess it's proxy issues. can you please check proxies please. - Abu Sufian
What is the error message? - Shubham Verma
The status code 404, means that the address does not exists. Are you sure that you are hitting the right route ? link - Lasse

2 Answers

0
votes

You should use some other content-type if you use formdata:

'Content-type':'multipart/form-data'
-1
votes

'http://serverip/users/login.json()....dot json() is missing