npm 之 request 的使用

2,200 阅读1分钟

post 请求


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

    }
});