2016-11-12 55 views
1

在这个片段中,我试图在后发送请求的URL参数作为身体的一部分:如何使用require('request')发送多个帖子参数;

var request = require('request'); 

    request.post({ 
    headers: { 'Content-Type' : 'application/x-www-form-urlencoded'}, 
    url : 'http://localhost:7777', 
    body : 'tosummarise='+data+'&url'+url 
    }, 

&url参数没有被设置。这是正确的方法发送request.post多个职位参数? tosummarise的值设置为

回答

0

我忽略了请求参数中的=。此代码有效:

var request = require('request'); 

    request.post({ 
    headers: { 'Content-Type' : 'application/x-www-form-urlencoded'}, 
    url : 'http://localhost:7777', 
    body : 'tosummarise='+data+'&url='+url 
    }, 
0

看起来像你的“身体”,这里应该是你的URL的一部分,而不是。实际的POST正文数据进入“正文”