I am submitting a form and the following gets called...
handleLogin(){
fetch('http://localhost:8080', {
method: 'post',
body: JSON.stringify({
username: this.state.username,
password: this.state.password
})
});
}
It makes a POST request to my restAPI. The request works, but the data is not passed...
app.post('/', function(req, res, next) {
console.log(req.body.username);
....
This prints out undefined, meaning password and username are not passed through the call. What am I doing wrong?
this.statebefore callingfetch().this.state, its all good. Ill check the networkreq.body? You will need to usebodyParse.json()as a middleware.req.bodyI get an empty array,{}, also on POST I get redirect to a pagecannot POSTbut yet it stillconsole.logeverything inside myapp.post