首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >post使用node.js中的request-promise模块并获取http_outgoing.js:618抛出新参数(‘first ERR_INVALID_ARG_TYPE’,error

post使用node.js中的request-promise模块并获取http_outgoing.js:618抛出新参数(‘first ERR_INVALID_ARG_TYPE’,error
EN

Stack Overflow用户
提问于 2019-12-03 08:56:14
回答 1查看 497关注 0票数 0

以表单的方式发送正文,以json的方式获取数据,并获得此错误,感谢您抛出新的参数(‘_http_outgoing.js:618 ERR_INVALID_ARG_TYPE’,^

TypeError ERR_INVALID_ARG_TYPE:第一个参数必须是字符串或缓冲区类型之一。接收类型对象位于write_ (_http_outgoing.js:618:11)、ClientRequest.write (_http_outgoing.js:586:15)、Request.write (C:\Users\DomKim\Desktop\workspaceForNode\node_modules\request\request.js:1500:27)、end (C:\Users\DomKim\Desktop\workspaceForNode\node_modules\request\request.js:549:18)、Immediate._onImmediate (C:\Users\DomKim\Desktop\workspaceForNode\node_modules\request\request.js:578:7)在processImmediate (内部/定时器:439:21){ code:'ERR_INVALID_ARG_TYPE‘

这是我的代码

代码语言:javascript
复制
async  function getConnection(url,param) {
 var queryStr = generateQueryString(param)
 var result ;
  console.log(queryStr);
  let OPTIONS = {
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      uri: url,
      method: 'POST',
      body:{
        queryStr
      },

  };await  request(OPTIONS).then(function(body){


           result = body;
          console.log('result in rquest.post : '+result);

   }).catch(function(err){
        console.log('error! : ' + err);
   });
   console.log('result out rquest.post : '+result);
   return result;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-03 09:04:07

您应该检查queryStr的类型。它应该是StringBuffer

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59148769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档