Answers for "node-fetch auth basic"

2

how to send basic auth using fetch

fetch(url, {
	...options, 
	headers: {
    	'Authorization': 'Basic ' + btoa(`${username}:${password}`)
    }
})
.then(response => response.json())
.then(json => console.log(json));
Posted by: Guest on October-11-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