Unable to detect http headers

4 answers

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

All answers to this question, which has the identifier 58637025

The best answer:

Try to set headers this way

const httpHeaders = new HttpHeaders()   .set('APP_KEY', 'ABCDEFGHJ');  this.http.get('<my_api_link>', httpHeaders) 

Try this :

var token = 'ABCDEFGHJ'; const myHeaders = new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': token }); this.http.get('<my_api_link>', { headers: myHeaders }); 

Or

let headers = new HttpHeaders(); headers = headers.set('APP_KEY','ABCDEFGHJ'); 

Modifying your code snippet :

const httpOptions = {   headers: new HttpHeaders().set('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); }); 

import {HttpClient} from '@angular/common/http';

constructor(private _httpClient: HttpClient) {

// some code

}

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data