I've been attempting to send an HTTP post request in Angular 2, but I'm facing difficulties setting the headers to content type application JSON.
This is my current code:
login(url, postdata) {
var headers = new Headers({'Content-Type': 'application/json'});
return this._http.post(url, JSON.stringify(postdata), this.headers)
.map(res => res.json())
}
Upon checking the network, I noticed that the Content-Type
is being set as text/plain
, which results in the server not receiving any data.
Any advice or suggestions would be greatly appreciated.