var postData = JSON.stringify({
'accesstoken': 'xxxx',
})
var options = {
hostname: 'https://cnodejs.org',
path: '/api/v1',
port: 443,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
var req = https.request(options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log(`主体: ${chunk}`);
});
res.on('end', () => {
console.log('响应中已无数据');
})
})
}```
无响应
↧
请问如何POST cnode社区的api?
↧