1fetch(url, {
2 ...options,
3 headers: {
4 'Authorization': 'Basic ' + btoa(`${username}:${password}`)
5 }
6})
7.then(response => response.json())
8.then(json => console.log(json));
1// for node-fetch
2
3fetch(url, {
4 ...
5 headers: {
6 'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`, 'binary').toString('base64')
7 }
8 ...
9})
10