Hello guys, I need to perform a GET operation with HTTP Native with the following headders. This is how I set the headers for the HttpClient from Angular:
const headers = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Basic ZTlSR3BseG53b0pKOG8yc1pEWmFmQUdlQjJUR3VJdVI6TEthYTVabXdDcVV5SnU5VA=='
})
};
How can I do this with HTTP Native? I can’t seem to be doing it properly and it doesn’t work if I just put the content in the curly brackets. This is what I am doing:
this.http2.get(ENTORNO.OBTENER_CITAS + nhc, {params: params }, {
'Content-Type': 'application/json',
'Authorization': 'Basic ZTlSR3BseG53b0pKOG8yc1pEWmFmQUdlQjJUR3VJdVI6TEthYTVabXdDcVV5SnU5VA=='
})
.then(data => {
console.log("ok");
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log("error");
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
Thanks.