http-client-status
Inspect/Check HTTP status code.
Install
$ npm install --save http-client-status
Usage
Get text description of code.
import { constants, codes, getStatusText } from 'http-client-status';
var httpClientStatus = require('http-client-status');
var constants = httpClientStatus.constants,
codes = httpClientStatus.codes,
getStatusText = httpClientStatus.getStatusText;
console.log(codes[404]);
console.log(codes[constants.NOT_FOUND]);
console.log(getStatusText(404));
console.log(getStatusText(constants.NOT_FOUND));
Check group.
import {
constants,
is_informational,
is_success,
is_redirect,
is_client_error,
is_server_error
} from 'http-client-status';
var httpClientStatus = require('http-client-status');
var constants = httpClientStatus.constants,
is_informational = httpClientStatus.is_informational,
is_success = httpClientStatus.is_success,
is_redirect = httpClientStatus.is_redirect,
is_client_error = httpClientStatus.is_client_error,
is_server_error = httpClientStatus.is_server_error;
console.log(is_informational(101));
console.log(is_informational(constants.SWITCHING_PROTOCOLS));
console.log(is_success(200));
console.log(is_success(constants.OK));
console.log(is_redirect(301));
console.log(is_redirect(constants.MOVED_PERMANENTLY));
console.log(is_client_error(404));
console.log(is_client_error(constants.NOT_FOUND));
console.log(is_server_error(500));
console.log(is_server_error(constants.INTERNAL_SERVER_ERROR));
Credits
This package is strongly inspired by: