I am invoking an API from angular JS front end and I am getting the 401 Unauthorized error. Here are the options I have tried.
Option 1:
$http({
method: "GET",
xhrFields: {
withCredentials: true
},
headers: {
Authorization: 'Basic ' + btoa('user:password')
},
url: 'http://localhost:11000/api/ping'
}).then(function(r) {
return Session.userId = r.headers('user');
})
Can you please help me in passing the credentials to backend API?