离子2本机http. -post执行在服务器上



我正在尝试使用cordova-plugin-http在Ionic 2应用中执行发布请求。但是当我运行时,它正在运行服务器。

import { HTTP } from 'ionic-native';
login(username:string, password:string){
    return HTTP.post(APIHOST + 'login', {username:username, password:password},{});
}

怎么了?

//you need to import this//
    import { Http, Headers, URLSearchParams, Request, RequestMethod, RequestOptions } from '@angular/http';     
   constructor(public navCtrl: NavController, private http: Http, private navParams: NavParams){}
        //login function
          Login(username, password) {
             //body for your details to be verified
        let data = {
                    "username": username,
                    "password": password,
                  }
    //here you are making an api call//
                  return this.http
                    .post(apiUrl + Login, data)
                    .map(res => res.json())
                    .subscribe(
                    data => {
            },
                    err => {
                      console.log("ERROR!: ", err);
                    }
                    );
            } 

相关内容

  • 没有找到相关文章

最新更新