Closed michealChin closed 6 years ago
The following example shows a Get request, I would like to know how to execute a POST request?
const options = { host: 'cnodejs.org', port: 80, path: '/', method: 'GET', agent: keepaliveAgent, }; const req = http.request(options, res => { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); }); }); req.on('error', e => { console.log('problem with request: ' + e.message); }); req.end();
agentkeepalive is just an alternative to httpAgent
agentkeepalive
About How to Send A Request, please refer to https://nodejs.org/api/http.html#http_http_request_options_callback
Hi,
I got it, Thanks!
The following example shows a Get request, I would like to know how to execute a POST request?