如何在http传递数组.请求节点
How Can I Pass Array in http.request node?
我想传递数组在我的路由POST
I Did try this
my object is
var myobj = [{name:'foo',name:'bar',name:'buz'}]
我想在http。request
中传递这些值var options = {
hostname : 'myhost',
port : 'myport',
path : 'myroute',
method : 'POST',
agent : false,
body : myobj,
headers : {'Content-Length': myobj.length}
};
var req = http.request(options,function(res) {});
router.post('myroute', function( req, res ){
//I want myobj here
console.dir(req.body); //EMPTY
})
I did try also
path : 'myroute'+myobj and i recived socket hang up
I did try also
json = JSON.stringify(docs);
req.write(JSON.stringify(myobj));
router.post('myroute', function( req, res ){
console.dir(req.body);
})
相关文章:
- 向多维数组添加值和从多维数组请求值
- 使用application/x-www-form-urlencoded使用node.js在post请求中发送数组
- 通过XHR请求将MYSQL数组从PHP返回到Javascript
- 如何显示从Ajax请求返回的数组.使用Yii2
- 使用Javascript数组或JSON来存储AJAX请求的返回值,以备将来使用
- 正在发送请求中包含数组的qx.io.request.Xhr请求
- 为什么我的猫鼬对象 Id 请求返回一个空数组
- 使用AngularJS$http.get在滚动时重复请求JSON数组
- jQuery ajax请求,将索引数组作为关键字字符串
- 如何迭代请求正文中的对象数组
- 使用jQuery.ajax请求向PHP函数发送一个对象数组
- 将jquery ajax请求推入数组时出错
- node.js请求POST数组“;第一个参数必须是字符串或缓冲区;
- 使用Jquery将JSON API请求的元素传递给数组
- 从多个API请求推送到全局数组
- 如何在 Node.js 中的 HTTP 请求后异步导出 JSON 数组
- php数组请求
- MongoDB通过_id数组请求(可能吗?)
- 处理循环数组请求的错误
- 如何在http传递数组.请求节点