【问题标题】:Expected 2-3 arguments , but got 1 (ionic ) typescript预期 2-3 个参数,但得到 1 个(离子)打字稿
【发布时间】:2018-11-24 00:59:19
【问题描述】:
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

【问题讨论】:

  • 请不要将错误信息发布为图片。复制粘贴文本。

标签: typescript ionic-framework


【解决方案1】:

它出错是因为method signature for put 是:

put(url, body, headers)

它在技术上仍然有效,因为该库恰好可以优雅地处理您隐式传递的 undefined 值。

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

put(url, {}, {})

【讨论】:

  • 非常感谢!
猜你喜欢
  • 2021-03-13
  • 1970-01-01
  • 2018-11-18
  • 2021-08-05
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
  • 2018-09-07
相关资源
最近更新 更多