Answers for "send auth header token node-fetch"

3

fetch with bearer token

fetch('URL_GOES_HERE', { 
   method: 'post', 
   headers: new Headers({
     'Authorization': 'Basic '+btoa('username:password'), 
     'Content-Type': 'application/x-www-form-urlencoded'
   }), 
   body: 'A=1&B=2'
 });
Posted by: Guest on October-29-2020
1

node-fetch auth basic

// for node-fetch

fetch(url, {
	... 
	headers: {
    	'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`, 'binary').toString('base64')
    }
    ...
})
Posted by: Guest on January-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language