basic authentication with fetch in react code example
Example: 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));