繁体   English   中英

ionic http请求未触发

[英]ionic http request not fired

我正在使用ionic v2,问题是当我发送http请求时,它未显示在chrome上

   export class Auth {

  constructor(public http: Http) {
    console.log('Hello Auth Provider');
  }

  login(){
    console.log('Hello');
    this.http.post('localhost:8100/api/User/getAll/' , '' , {});

  }

}

我启动登录方法,它可以退出“ Hello”,但不会启动http

这意味着ionic不会触发http调用,我已经安装了白名单插件,编辑xml文件并安装了chrome扩展名,但是这些都解决不了问题

您必须map()响应,然后使用subscribe()方法,因为有角度的Http使用Observables 检查这个

this.http.post('localhost:8100/api/User/getAll/' , ''  {})
 .map(res => res.json())
 .subscribe(
    response => {
       console.log(response);
     },
    error => {console.log(error)
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM