I read many posts about how to send json to express via post but none worked or fixed my issue.
my issue is that when reading req.body
where req
is the request object
i get an output like this : { '{"z":"z"}': '' }
for this obejct i sent {z:"z"}
That is not expected and not any kind of behavior is saw before.
this si the angular httpClient request :
return new Promise((res,rej)=>{
this.http.post("http://localhost:3000/Auth/Login",{z:"z"},{headers:new HttpHeaders('Content-Type:application/x-www-form-urlencoded')})
.toPromise()
.then(
response =>{
res(response)
}
).catch(
err=>{
rej(err)
}
)
})
This is the server code :
router.route('/Login').all(function (req, res, next) {
next();
}).post(function(req, res, next) {
console.log(req.body);})
what i want is to get the same object i sent that is it.
Help !