Ionic:代理添加成功,但是在调用它时出现404错误

时间:2018-08-10 05:43:21

标签: angular ionic-framework ionic2 ionic3

这是ionic.config.json

{
  "name": "projectSniper",
  "integrations": {
    "cordova": {}
  },
  "type": "ionic-angular",
  "pro_id": "5d7f8490",
  "typescript": "true",
  "proxies": [{
    "path": "/apibase",
    "proxyUrl": "http://api.esmox.apprells.com/3.0/stats/custom?slice[]=year&slice[]=month&slice[]=day&filter[date_from]=2017-03-01&filter[date_to]=2018-08-01&conversionTypes[]=confirmed&conversionTypes[]=total&limit=10&api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }]
}

在编译时在CLI中显示它已添加api;我在浏览器中检查了链接,链接正确!

  

添加了代理:/ apibase => [应用脚本]   http://api.esmox.apprells.com/3.0/stats/custom?slice[]=year&slice[]=month&slice[]=day&filter[date_from]=2017-03-01&filter[date_to]=2018-08-01&conversionTypes[]=confirmed&conversionTypes[]=total&limit=10&api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

这是api调用部分:(Ionic / Typescript)

private myUrl: string = `/apibase`;

callApi() {
    this.heads.append('access-control-allow-headers','content-type,accept,access-control-allow-origin, access-control-request-method,access-control-allow-headers');
    this.heads.append('access-control-maximum-age','1000');
    this.heads.append('content-type','application/json');
    this.heads.append('accept','application/json, text/plain, */*');
    this.heads.append('Origin','*://*/*');
    this.heads.append('referer','*://*/*');
    this.heads.append('access-control-allow-origin','*');
    this.heads.append('access-control-request-method','GET, POST, OPTIONS');

    this.options = {
      url: this.myUrl,
      method: 'GET',
      headers: this.heads
    };



    this.http.request(this.myUrl,this.options).subscribe(data => {

      var jsonRes = JSON.stringify(data);
      console.log(jsonRes);


    });


  }

我收到的错误响应为 {“状态”:2,“错误”:“未找到页面”}“,状态:404,确定:否

您能告诉我我在这里做错了吗...非常感谢...!

0 个答案:

没有答案