Phong Duong

🔎Search

Get HTTP status codes and description with Node.js

03-02-2021 | #nodejs

To get all HTTP status codes and their descriptions with Node.js, you get the STATUS_CODES property of the http module.

require("http").STATUS_CODES
/*
  {
    '100': 'Continue',
    '101': 'Switching Protocols',
    '102': 'Processing',
    '103': 'Early Hints',
    '200': 'OK',
    '201': 'Created',
    '202': 'Accepted',
    ...
  }
*/

This property contains an object of status codes and descriptions.

Share: TwitterFacebookLinkedInHacker News