节点JS请求模块未发送表单数据 [英] Node JS request module does not send form data

查看:80
本文介绍了节点JS请求模块未发送表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用节点js中的请求"模块发出发布请求,如下所示:

I am making a post request using "request" module in node js like this:

 request.post({url: 'http://localhost:4004/api/v1/notifications/post', form: {msg:msg, userID:userID}}, function(err, httpResponse, body){
    if(err) return 0;
    else return 1;
});

没有服务器端,我收到了请求,但是参数没有出现.我在做什么错了?

no the server side I get the request, however the parameters do not come. What am I doing wrong?

推荐答案

我认为您必须对表单数据进行字符串化并将其放入正文中.这是一个已回答的类似问题: POST请求在node.js中使用请求模块无法正常工作

I think you have to stringify your form data and put it in the body. Here is a similar question that has been answered: POST Requests not working using request module in node.js

这篇关于节点JS请求模块未发送表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆