I need to make calls with this format
https://username:password@my.domain.com/api
in ajax I did something like this
$.ajax({
url: endPoint,
type: 'POST',
async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
username: myUsername,
password: myPassword,
beforeSend: function (xhr) {
xhr.withCredentials = true;
xhr.setRequestHeader("Accept", "application/json; odata=verbose");
}
});
how can i do the same with the new w500> without doing something like this?
let url = baseProtocol + username + ":" + password + "@" + baseUrl
this.http.post(url,{
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
}
}).subscribe( res => {
}, err => {
}
it works, but this string concatenation is ugly. I am not a specialist in this kind of technology, I would appreciate help
source
share