Ionic framework 在HTTP.get中传递头

Ionic framework 在HTTP.get中传递头,ionic-framework,ionic-native,Ionic Framework,Ionic Native,我在做一个项目,我在和JWT打交道,不管怎样,我试着发送post请求,它很有魅力,但当我尝试以同样的方式发出get请求时,它不起作用。 这是我的密码: ionViewWillEnter(){ this.storage.get('token').then((val) => { this.token = val console.log(this.token); let link = Constants.API_ENDPOINT+"/v1/owner/section/list"; con

我在做一个项目,我在和JWT打交道,不管怎样,我试着发送post请求,它很有魅力,但当我尝试以同样的方式发出get请求时,它不起作用。 这是我的密码:

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);

});
});
}
我得到以下输出:

 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
所以基本上我得到了一个错误,但爱奥尼亚不会显示它

注意:


我已在
Postman
中向同一链接发送了一个标题相同的请求,它返回了正确的响应

我非常怀疑您的响应HTTP标题本身是JSON格式的,这一行暗示了这一点:

var hdrs=JSON.parse(data.headers)


标题可能只是键/值对的映射,而不是JSON编码的。我想知道该行是否抛出了异常,从而中止了on success处理程序的其余部分。

我补充说,在我收到这些错误后,无论如何我已经删除了它,现在我得到了错误号500