离子本机http获取请求中出现错误“类型错误:无法将未定义或空值转换为对象”

时间:2019-05-17 08:27:35

标签: ionic3 ionic-native-http

在离子本机HTTP获取请求中出现错误“类型错误:无法将未定义或null转换为对象”

enter image description here

getDetail() {
let loading = this.loadingCtrl.create({
  spinner: "bubbles"
});
loading.present();
var myData = {};
let headers = {
  "Content-Type": "application/json; charset=utf-8",
  "cache-control": "no-cache"
};
//I have tried to add time out but not working 
this.http.setRequestTimeout(5);
this.http
  .get(global.apiUrl + "homepagedetails", myData, headers)
  .then(data => {
    this.tmpDetail = JSON.parse(data.data);
  })
  .catch(error => {
    //==> getting error alert here
    alert(JSON.stringify(error, Object.getOwnPropertyNames(error)));
    loading.dismiss();
  });
}

0 个答案:

没有答案