Hi
I’m working on a project and I’m dealing with JWT, anyway I have tried to send post requests and it went as a charm but when I tried to make get requests the same way is not working.
here is my code :
ionViewWillEnter(){
this.storage.get('token').then((val) => {
this.token = val
console.log(this.token);
let link = Constants.API_ENDPOINT+"/v1/owner/section/list";
console.log("Debugging");
console.log(link);
this.http.get(link,{},{Authorization: "Bearer "+val})
.then(data =>{
var hdrs = JSON.parse(data.headers);
var res = JSON.parse(data.data);
console.log(res);
console.log(hdrs)
})
.catch(error =>{
console.log("Yup Errors area ")
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
});
}
I get the following output :
Debugging
(the correct link)
Yup Errors area ["a message I have set to make sure that the code executed the catch method"]
undefined
undefined
undefined
any idea why am I getting this errors ?
Note :
I have sent a request to the same link with the same headers in Postman
and it returned the correct response