小编Zac*_*c S的帖子

node js使用原始请求主体发送post请求

var req ={
      "request": {
        "header": {
          "username": "name",
          "password": "password"
        },
        "body": {
        "shape":"round"    
    }
      }
    };

    request.post(
        {url:'posturl',

        body: JSON.stringify(req),
        headers: { "content-type": "application/x-www-form-urlencoded"}
        },
        function (error, response, body) {        
            if (!error && response.statusCode == 200) {
                console.log(body)
            }
        }
    );
Run Code Online (Sandbox Code Playgroud)

我想在req变量中发送原始请求体.它正在邮递员,但在节点js我无法发送原始json作为发布请求的请求主体.

post node.js

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

node.js ×1

post ×1