Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 649

How to set headers to the content type application/json in Angular 2?

$
0
0

I'm trying to send HTTP post request in Angular 2, but I'm not able to set headers to the content type application/json.

My code is:

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())    }

When I checked in network, I found that Content-Type is set as text/plain, and thus the server is not receiving any data.

Any suggestions will be appreciated.


Viewing all articles
Browse latest Browse all 649

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>