request.post
Send an HTTP POST request.
js
request.post(input, options?, callback)Arguments
| Argument | Type | Meaning |
|---|---|---|
input | string | object | URL string or options object. |
options | object | Optional url/uri, method, headers, string body, json, form, qs and timeout (milliseconds). |
callback | function | (error, response, body). Response has statusCode, lowercase headers, body and url. |
Returns
Request handle with abort().
Example
js
const request = require("request");
request.post("https://example.com", {timeout: 5000}, (error, response) => {
if (error) throw error;
console.log(response.statusCode);
});Notes
Use your own endpoint. HTTP error status is a response, not a transport error.