javascript - 请求 JS Uri 请求错误

标签 javascript node.js express

我正在尝试使用 Request JS 发布到服务器。我在部分路径上遇到问题。

return await request.get({
      method: 'POST',
      uri: `${domain}/info/test/`,
      body: bodyAsString,
      headers: {
        Authorization: `bearer ${token}`,
      },
    }).pipe(res);

此 api 有两种方法可以命中它:/info/test 作为 POST 和 /info/test/:GUID 作为 GET。出于某种原因,当我使用请求访问 API 时,它会提示“测试”不是有效的 GUID,就像我在路径上的级别太低一样。我可以在 Postman 中正常点击它。

最佳答案

你应该使用 request.post 而不是 request.get

关于javascript - 请求 JS Uri 请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48067492/

相关文章:

javascript - 在 Chart.js v2.x 中放置 "multiTooltipTemplate"的位置

python - 从 python spawn 子进程接收连续输出不起作用

javascript - Node : Fully executing websocket responses sequentially with async calls

node.js - res.send 和 res.json 的区别

node.js - 使用 Express 的多个证书/虚拟主机

node.js - 允许同时使用字符串文字和 JSON 对象作为请求

javascript - 提交表单时将 div 滚动到顶部

javascript - JavaScript 中的 "callback"关键字

node.js - 将事务序列化为 Express 中间件

javascript - ng-重复 : Don't duplicate the types in a select