I need to make a http get request with a basic authentication, but I do not know how. I am using ionic2, angular & typescript. My code:
this.http.get("http://address")
.map(res => res.json())
.subscribe( data =>{
console.log(data);
});
From the Ionic doc I see what I need, but I am new to these technologies and I am not able to use it: useBasicAuth(username, password)
I have tried these solutions, but it did not work: Angular 2- Http POST request parameters
EDIT
I have been trying the code below
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Basic xxxxxxx=');
let options = new RequestOptions({ headers: headers });
this.http.get("http://VLCwebServerAddress",options)
or even
this.http.get("http://VLCwebServerAddress",headers)
If the second parameter is headers I get the response 401, so the Auth failed.
If the second parameter is options I get Response for preflight has invalid HTTP status code 501
which I've read it's related with CORS in the server side.