HTTP Info
HTTP Status Codes Utility
A set of utility that allow to match, convert and list HTTP status codes.
Complete list of HTTP Status Codes can be found here.
Installation
$ npm install http-info
Usage
// ConverthttpInfo // => Continue // MatchhttpInfomatch // => true // ListhttpInfolistserverError // => [500, 501, 502, 504, 505, 506, 507, 508, 510, 511]
API
convert(code)
Convert any HTTP code to its status message.
Code
type number
Return
string
| null
Example
httpInfo // => ContinuehttpInfo // => Moved Permanently // False value will return nullhttpInfo // => null
match[<group>](code)
Returns whether an HTTP code exists in the specified group.
Group
informational
, success
, redirection
, clientError
, serverError
, _any
Code
type number
Return
boolean
Example
httpInfomatch // => truehttpInfomatch // => false // To check for all groups, use `_any`httpInfomatch // => true
list[<group>]
Group
informational
, success
, redirection
, clientError
, serverError
Return
array
Example
httpInfolistsuccess // => [200, 201, 202, ...]httpInfolistserverError // ==> [500, 501, 502, ...]