for example: to transfer a obj to /localhost/transfer
var request = require('request');
var obj={
tag: 'false',
array: [ '3', '4', '5']
}
request.post({url:/localhost/transfer, form:obj},function(err,httpResponse,body){
if(err){
res.json({error:false});
}else{
res.json({error:true});
}
});
get obj
router.post('/transfer',function(req, res, next){
console.log(req.obj);
});
the console obj display:
{ tag: 'false',
'array[0]': '3',
'array[1]': '4',
'array[2]': '5' }
How to send or receive data correctly? like this
{
tag: 'false',
array: [ '3', '4', '5']
}
request: https://github.com/request/request#custom-http-headers