I’ve setup my api into web server, currently im unable to retrieve data using my app key but able to do so using postman, please do help
const httpOptions = {
headers: new HttpHeaders({
'APP_KEY': 'ABCDEFGHJ'
})
};
this.http.get('<my_api_link>', httpOptions).subscribe((res) => {
this.Result = JSON.stringify(res);
console.log('Result', this.DataResult);
}, (err) => {
console.error(err.status);
console.error(err.error); // Error message as string
console.error(err.headers);
});
Error message was unable to find app key
4
Answers
Try to set headers this way
Try this :
Or
Modifying your code snippet :
import {HttpClient} from ‘@angular/common/http’;
constructor(private _httpClient: HttpClient) {
// some code
}