I use HttpClient in Angular to send formdata to Nodejs.
resetPasswordRequest(email){
this.httpOptions={
headers: new HttpHeaders({
'Content-Type':'application/x-www-form-urlencoded'
})
}
const formData = new FormData();
formData.append('email',email);
return this.http.post("http://localhost:3001/forgotPassword",formData,this.httpOptions);
}
Later in NodeJS,I have app.use(bodyParser.urlencoded({extended:true}).
I am able to get req.body but in a different format as below:
{ '-----------------------------24875245787704\r\nContent-Disposition: form-data; name':
'"email"\r\n\r\abcd@gmail.com\r\n-----------------------------24875245787704--\r\n' }
I am not sure what has been missed. Could you please clarify and help get value of email? I get req.body.email as undefined.