I'd like to know why my Chrome Dev Tools is not showing the headers I put on a request. I would like to send a request to Twitter API and it requires an Authorization header.
I am executing the following code:
getTweets(hashtag : string){
var headers = new Headers();
headers.append('Test-Test', '123456789');
headers.append('Authorization', 'Bearer AAAAAAAAAAAAAAAAAAAAAONruQAQda4njz64ske7axXN9sw4U0oU%3Dr1niTwVKwXomZczDKgN0wWHWEMPrPcnXXMgVQhiTIzays7J');
return this.jsonp.get('https://api.twitter.com/1.1/search/tweets.json?q=canada&callback=JSONP_CALLBACK', {headers: headers});
}
However it is not returning the data as expected.
When I go to the Chrome Dev Tools, I do not see the headers I added listed in the request.
Why is this? Am I not adding the headers properly? Does Chrome Dev Tools only display the basic headers? What's going on?
There is no way to control headers sent by a browser while using JSONP. JSONP is a smart trick (or a hack, depending on how you see it...) that consist of inserting a <script>
tag pointing to a server endpoint. Ultimately it is a browser who will decide which headers to sent while requesting scripts via <script>
tag and you can't influence it.
From : https://stackoverflow.com/a/19604865/3279156
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With