Request with URL that includes credentials Request with URL that includes credentials reactjs reactjs

Request with URL that includes credentials


You can't use the https://user:pass@host.com form, you need to set the Authorization http Header:

var headers = new Headers();headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));fetch('https://host.com', {headers: headers})

Where btoa encodes 'user:pass' to base64 encoded string. You can find btoa function availability on MDN (in short: it works on IE 10 and above).