I'm trying to make POST request on node.js to url, but always get ERROR 401 (Unauthorized).
const response = await fetch('url', {
method: 'POST',
mode: 'no-cors',
headers: {
"Content-Type": "text/html; charset=utf-8",
"Authorization": 'Basic ' + Buffer.from('username' + ":" + "password", 'base64').toString('base64')
},
body: ''
});
I'm tried to use btoa, however node.js does not support that...
headers.set('Authorization', 'Basic ' + btoa(username + ":" + password));