打字稿错误" [ts]预期0-2参数,但在Ionic 3 Framework中得到3。"

时间:2018-05-22 12:44:12

标签: angular typescript ionic3

这是我正在制作的http请求我正在使用ionic-native / http插件 我得到的错误是 的错误

[ts] Expected 0-2 arguments, but got 3.

这是我正在制作的Http电话

  getAcknowledgmentRequest(ssoId, alertType) {

    var url = this.globals.getUrl() + "receive_orderM";
    var body = JSON.stringify({ sso_id: ssoId, alert_type: alertType });    

    let bearer = 'Bearer ' + this.globals.getAccess();
    let headers = { 'Accept': 'application/json' , 'Authorization': bearer };

    return this.http.post(url,body,headers).then(
      (resp: HTTPResponse) => {
    return resp.data;
     })
  .catch((error: any) => {
      console.log(error);
  });
  }

这是调用我的服务的方法

this.messageService.getAcknowledgmentRequest(sso_id,alertType).then(
        (response: any) =>{   
            this.responseData =data;
            this.orders =this.responseData ;
            if (this.orders.length == 0) {
              this.showMessage = true;
            }
            loading.dismiss();         
        },
         catch(error => {
     Console.log(error);
})

1 个答案:

答案 0 :(得分:1)

我认为post的正确正文是一个对象,而不是一个字符串:

var body = JSON.stringify({ sso_id: ssoId, alert_type: alertType });  

应该是:

var body = { sso_id: ssoId, alert_type: alertType };