isSkipSelf错误没有在Ionic 2中触发HTTP Get

时间:2016-06-07 08:43:38

标签: http ionic2

EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'isSkipSelf' of null

在触发Http get请求后,返回上述错误。代码如下:

import {Page, NavController} from 'ionic-angular';
import { Http, Headers, HTTP_PROVIDERS } from 'angular2/http';
import {Injectable} from 'angular2/core';
import 'rxjs/add/operator/map';

@Page({
    templateUrl: 'build/pages/weekview/weekview.html',
    providers: [HTTP_PROVIDERS]
})

@Injectable()
export class WeekViewPage {

    http: any;
    nav: any;

    constructor(http: Http, nav: NavController) {
       this.http = http;
       this.nav = nav;

       this.http.get("URL?username=jsmith&age=21")
        .subscribe(data => {
            console.log(JSON.stringify(data.json()));
        }, error => {
            console.log(JSON.stringify(error.json()));
        });
   }
}

我使用了谷歌应用脚​​本教程中的示例参数:https://developers.google.com/apps-script/guides/web#url_parameters

在浏览器中,我尝试使用相同的URL并返回预期结果:

{
  "queryString": "username=jsmith&age=21",
  "parameter": {
    "username": "jsmith",
    "age": "21"
  },
  "contextPath": "",
  "parameters": {
    "username": [
      "jsmith"
    ],
    "age": [
      "21"
    ]
  },
  "contentLength": -1
}

我已经在ionic2上搜索了很多关于ionic2的HTTP教程,但是有些代码有不同版本的代码,所以我尝试将它们混合起来但没有成功。请帮忙。

*注意:出于安全考虑,我创建了一个公共网址,仅用于测试此问题/主题:https://script.google.com/macros/s/AKfycbz8Uch1TJ2PfCCMJSEBmbAXhKD-_DagFesbDWKWlTSups-9Zt4/exec

编辑:这是isSkipSelf仍然存在的代码:plnkr.co/edit/EkGuHtJ1IpRBJ4gcTiAZ

1 个答案:

答案 0 :(得分:0)

我现在已经“修复”了......使用--disable-web-security flag ...