A simple way to catch HTTP statuses with JavaScript.
js-http-status is available on npm/yarn:
$ npm install @codevor/js-http-status --save
$ yarn add @codevor/js-http-status
Access documentation clicking here.
Practice and learn here.
With ES6/import
import {
findStatusByCode,
findStatusByKey,
isCreated,
isOk
} from 'js-http-status';
findStatusByCode(200);
// => { code: 200, key: 'OK', message: 'OK', category: 'SUCCESS' }
findStatusByKey('TOO_MANY_REQUESTS');
// => { code: 429, key: 'TOO_MANY_REQUESTS', message: 'Too Many Requests', category: 'CLIENT_ERROR' }
isCreated(201); // => true
isCreated(500); // => HTTPStatusError: Expected a 201 response.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the Github Releases page.
Report bugs or do suggestions using the issues.