I\'m trying to fetch a curl and get a JSON from an API.
curl -XPOST -d \"grant_type=password\" -d \"username=admin@admin.admin\" \\
-d \"password=admin\
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).