离子3本机HTTP不允许我访问JSON数据

时间:2017-08-28 05:59:09

标签: javascript json typescript ionic2 ionic3

我正在使用离子3本机HTTP向我的后端服务器发送POST请求,后者返回JSON数据但是当我尝试从变量访问该对象时出现错误:

  

[ts]财产' InRepair'类型' {}'上不存在。   任何

不确定我做错了什么。

我的POST请求函数是一个提供者,这是

的代码

HttpProvider.ts

    import { HTTP } from '@ionic-native/http';

@Injectable()
export class TekItapiProvider {
apiURL = 'myAPISeverURL';

constructor(private http: HTTP) {
}

  doPost(url, data) {
    var endpointURL = this.apiURL + url;
    return new Promise((resolve, reject) => {

      this.http.post(endpointURL, data, this.headers)
        .then(data => {
          resolve(data.data);
        })

        .catch(error => {
          console.log(error.status);
          reject(error);
        })
    })
  }

}

这是调用它的地方,也是我尝试访问该对象的地方。在状态我可以访问.completed,因为它给了我错误:[ts]属性' InRepair'类型' {}'上不存在。 任何

request.ts

this.httpProvider.doPost(myURL, '')
.then((status) => {
     if (status.completed == 'Yes') {

     }
     },(err) => {

     })

你们知道我在这里做错了吗?

0 个答案:

没有答案
相关问题