nodejs使用request发送post请求

/**
 * Created by 斗酒 on 2018/1/16.
 */
var request = require('request');
var url="地址";
var requestData="上送的数据";

httprequest(url,requestData);

function httprequest(url,data){
    request({
        url: url,
        method: "POST",
        json: true,
        headers: {
            "content-type": "application/json",
        },
        body: requestData
    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body) // 请求成功的处理逻辑
        }
    });
};




你可能感兴趣的:(nodejs)