![]() |
VOOZH | about |
The http.IncomingMessage.statusCode is an inbuilt application programming interface of class IncomingMessage within HTTP module which is used to get the 3-digit HTTP response status code.
Syntax:
const message.statusCode
Parameters: This method does not accept any argument as a parameter.
Return Value: This method returns the 3-digit HTTP response status code.
Example 1: Filename: index.js
Run the index.js file using the following command.
node index.js
Output:
Server is running at port 3000... null 200 displaying the result... server is closed
Now go to http://localhost:3000/ in the browser, and you will see the following output:
statusCode : null
Example 2: Filename: index.js
Run the index.js file using the following command.
node index.js
Output:
Server is running at port 3000... displaying the result... server is closed
Now go to http://localhost:3000/ in the browser, and you will see the following output:
Request statusCode Not Set
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_message_statuscode