Nodejs 发送 POST 请求


Nodejs 发送 POST 请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let request = require('request');

let header = {
"Content-type": "application/json",
"Accept": "application/json",
"Cache-Control": "no-cache",
};
let contents = {
id: 1,
};

request({
"uri": url,
"headers": header,
"method": "POST",
"json": contents,
},
async (err, res, body) => {
if (!err&&body) {
body = JSON.parse(body);
} else {

}
});