I've been following a tutorial here but ran into some issues due to using newer versions of Angular and Ionic.
This is an excerpt from my code:
createReview(review){
let headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
this.http.post('http://localhost:8080/api/reviews', JSON.stringify(review), {headers: headers})
.subscribe(res => {
console.log("creating new review.." + res);
});
}
The createReview() function is supposed to send a JSON POST request with all the review data to my NodeJS server, but it seems the server is receiving 'undefined' instead.
POST /api/reviews 200 222.839 ms - 309
creating review
title: undefined
description: undefined
rating: undefined
When using POSTMAN, I set 'Content-Type: application/json' in the Headers and sent the following raw JSON data:
{
"title":"postman tt",
"description":"postman desc",
"rating":"30"
}
The server was able to receive this data without any issue. What changes should I make in my code?
Appreciate any help!