8

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.

Chrome Dev Tools Request

Why is this? Am I not adding the headers properly? Does Chrome Dev Tools only display the basic headers? What's going on?

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
  • 2
    This is not a duplicate question and the answer linked to as the original "duplicate" does not answer the actual question. The problem is with Chrome Dev Tools network tab not showing all headers of a request. I'm having the same issue where the "Headers" tab does not show all request headers. – Joshua Kemmerer Jan 08 '19 at 18:21

1 Answers1

1

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

Community
  • 1
  • 1
sreeramu
  • 1,213
  • 12
  • 19