为了账号安全,请及时绑定邮箱和手机立即绑定

无法正确读取http请求

无法正确读取http请求

ITMISS 2023-09-14 18:08:42
我正在尝试使用 axios 来更新数据,并且我想在请求网址中使用“id”,例如 http://localhost/api/firstmemory/1但返回 500 Internal Server Error,因为我的 id 无法正确读取。我的代码    const id = detail.id;    const updateFirstInfo = (e) => {    const upInfo = {        first: first,        date: change,        memo: memo,    }    console.log(id); //1       axios      .put(`api/firstmemory/${id}}`, upInfo)      .then(res => {        console.log("ok");      })      .catch(err => {        alert("err");      });  };我该如何修复它?
查看完整描述

1 回答

?
www说

TA贡献1775条经验 获得超8个赞

%7D是 字符 的 HTML 编码}。}如果你仔细观察,你会发现在使用模板字符串的地方有一个额外的地方。删除多余的}:


axios

  .put(`api/firstmemory/${id}`, upInfo)

  .then(res => {

    console.log("ok");

  })

  .catch(err => {

    alert("err");

  });

希望这有帮助!


查看完整回答
反对 回复 2023-09-14
  • 1 回答
  • 0 关注
  • 76 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信