node-rest-client
node-rest-client copied to clipboard
How to get HTTP status code
I need to get the status code in the answer. How can I retrieve this value ? (200 OK, 401...)
Hi I was able to doit with response.statusCode. It gives me the code of response object.
`var req = client.post("http://XXXXXXXXXXX", args, function (data, response) { console.log(data); // raw response console.log(typeof response); console.log(response.statusCode); /* for(var propertyName in response) { // you can get the value like this: myObject[propertyName] console.log(propertyName); } */
});`
@fvisticot This is the correct answer, so you should close the ticket.