简体   繁体   中英

HTTP request with authorization header

I'm going to ask a very simple question, yes it is really simple for every developer but not for beginner (maybe).

Let's me ask, I want to send HTTP request from browser when user click a button and I also want to add authorization header to the HTTP request.

I did this same thing with postman. In case of postman there are field to add headers to a request. But, how to do this same things with browser? I'm using node JS.

You can use the following sample code to make an HTTP Request using fetch:

fetch('URL', { 
   method: 'post', 
   headers: {
     'Authorization': 'YOUR_TOKEN', 
   }
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM