Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用请求模块发出 http post 请求
text = 'some data'; request.post('http://example.com/read', {form:{data: text}});
这适用于简单的字符串,但我需要能够发送数组或对象。
当我尝试在后处理程序中读取数组/对象时,数据属性为空。
这是怎么回事?您的帮助将不胜感激。
尝试这个:
var request = require('request'); request({ method: 'POST', uri: 'http://example.com/read', body: {'msg': 'secret'}, json: true }, function (error, response, body) { console.log('code: '+ response.statusCode); console.log(body); })
让我知道它是否有效。