预期2-3个参数,但得到1(离子)打字稿

时间:2018-06-14 09:36:59

标签: typescript ionic-framework

registerStudent(id,cName)
{
  return this.http.put("http://localhost:3000/api/registerOnlyThisStudent/"+id+"/"+cName).subscribe((res) =>{console.log(res.json());
 });
}

markRegistered(id)
{
  return this.http.put("http://localhost:3000/api/markRegistered/"+id).subscribe((res) =>{console.log(res.json());
 });
 }

  unRegister(sName ,cName )
   {
    return this.http.put("http://localhost:3000/api/UnRegister/"+sName+"/"+cName).subscribe((res) =>{console.log(res.json());
   });
     }

This is the error ,the code works perfectly fine in the browser but when I try to run the command ionic cordova run android , the compiler gives this error. please help me solve this issue

1 个答案:

答案 0 :(得分:2)

错误是因为method signature for put是:

put(url, body, headers)

它在技术上仍然有效,因为库恰好处理了您隐式传递的undefined值。

如果您不想发送数据或标题,可以使用空对象解决此问题:

put(url, {}, {})