the code below performs a rest call from a react.js frontend a backend node.js but when I execute the rest call I see on the backend Error: Illegal argument undefined, to remedy this I tried to make a rest call in postman and everything works correctly where is the error?
Frontend React.js:
import axios from 'axios';
import server from "../../../config/config";
import qs from 'qs';
restlogin(email,password){
const data = { 'Email': email,'Password': password };
const options = {
method: 'POST',
headers: { 'content-type': 'application/json' },
data: qs.stringify(data),
url: "http://172.16.53.248:8989/login"
}
axios(options);
}
Backend Node.js
app.post("/login", async function(request, response) {
var ret = false;
try {
//var data = request.body;
var data = request.body;
console.log("\n Email: "+data.Email+"\n Password: "+data.Password);
ret = await UserController.Login(
data.Email,
data.Password
);
} catch (err) {
ManageError.SendError("Errore in login: " + err);
ret = false;
}
response.setHeader("Content-Type", "application/json");
response.send(
JSON.stringify({
return: ret
})
);
});