HTTP Status Series
A simple utility for checking HTTP status codes.
Inspired by HttpStatus
in the Spring Framework.
Install
npm install http-status-series
API
Constants
Constant | Value |
---|---|
INFORMATIONAL | 1 |
SUCCESSFUL | 2 |
REDIRECTION | 3 |
CLIENT_ERROR | 4 |
SERVER_ERROR | 5 |
Methods
getSeries(statusCode)
Returns the series of the statusCode.
Example
httpStatus 2
isInformational(statusCode)
Returns true
if the HTTP status series is informational (1XX).
Example
httpStatus truehttpStatus truehttpStatus falsehttpStatus false
isSuccessful(statusCode)
Returns true
if the HTTP status series is successful (2XX).
Example
httpStatus truehttpStatus truehttpStatus falsehttpStatus false
isRedirection(statusCode)
Returns true
if the HTTP status series is a redirection (3XX).
Example
httpStatus truehttpStatus truehttpStatus falsehttpStatus false
isClientError(statusCode)
Returns true
if the HTTP status series is a client error (4XX).
Example
httpStatus truehttpStatus truehttpStatus falsehttpStatus false
isServerError(statusCode)
Returns true
if the HTTP status series is a server error (5XX).
Example
httpStatus truehttpStatus truehttpStatus falsehttpStatus false
License
HTTP Status Series is licensed with The BSD 2-Clause License