【问题标题】:How to implement jsonp get request in ionic 2?如何在 ionic 2 中实现 jsonp get 请求?
【发布时间】:2018-11-28 01:11:25
【问题描述】:

这是我的代码。

     this.jsonp.request(url, { method: 'Get' })
     .map(res => res.json()})
     .subscribe(
        data => {
         //success code
        },
        error => {
         //error code
        }
      )

问题是函数总是执行错误代码块。并且在浏览器中响应是 200 ok。

【问题讨论】:

    标签: angular ionic-framework jsonp


    【解决方案1】:
    Note: import Httpmodule and inject to appmodule
    
    import { Http } from '@angular/http';
    import 'rxjs/add/operator/map';
    ......
    ......
    
     public http: Http,
    .....
    ......
    
            let url="http://XXXX.XXXXX.XXXXX/1/forms";//put URL of JSON here
    
            this.http.get(url).map(res => res.json()).subscribe(resp => {
    
              console.log(resp);
             });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      • 2021-09-19
      • 2018-01-18
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      相关资源
      最近更新 更多