【问题标题】:How to send multiple post parameters using require('request');如何使用 require('request') 发送多个 post 参数;
【发布时间】:2017-03-26 14:55:50
【问题描述】:

在这个 sn-p 中,我试图在 post 请求中发送一个 url 参数作为正文的一部分:

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 值已设置

【问题讨论】:

    标签: node.js http-post


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      看起来您的“正文”应该是您的网址的一部分。实际的 POST 正文数据进入“正文”

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-10-25
        • 1970-01-01
        • 1970-01-01
        • 2019-10-06
        • 2017-07-08
        • 1970-01-01
        • 1970-01-01
        • 2015-09-06
        相关资源
        最近更新 更多