http-client-status

    1.0.1 • Public • Published

    http-client-status Build Status

    Inspect/Check HTTP status code.

    Install

    $ npm install --save http-client-status
    

    Usage

    Get text description of code.

    // ES6
    import { constants, codes, getStatusText } from 'http-client-status';
     
    // or
    var httpClientStatus = require('http-client-status');
    var constants = httpClientStatus.constants,
        codes = httpClientStatus.codes,
        getStatusText = httpClientStatus.getStatusText;
     
    console.log(codes[404]); 
    //=> Not Found
     
    console.log(codes[constants.NOT_FOUND]);
    //=> Not Found
     
    console.log(getStatusText(404)); 
    //=> Not Found
     
    console.log(getStatusText(constants.NOT_FOUND));
    //=> Not Found

    Check group.

    // ES6
    import {
      constants,
      is_informational,
      is_success,
      is_redirect,
      is_client_error,
      is_server_error
    } from 'http-client-status';
     
    // or
    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)); 
    //=> true
     
    console.log(is_informational(constants.SWITCHING_PROTOCOLS)); 
    //=> true
     
    console.log(is_success(200)); 
    //=> true
     
    console.log(is_success(constants.OK)); 
    //=> true
     
    console.log(is_redirect(301)); 
    //=> true
     
    console.log(is_redirect(constants.MOVED_PERMANENTLY)); 
    //=> true
     
    console.log(is_client_error(404)); 
    //=> true
     
    console.log(is_client_error(constants.NOT_FOUND)); 
    //=> true
     
    console.log(is_server_error(500)); 
    //=> true
     
    console.log(is_server_error(constants.INTERNAL_SERVER_ERROR)); 
    //=> true

    Credits

    This package is strongly inspired by:

    Install

    npm i http-client-status

    DownloadsWeekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • joelmcs6
    • albertomr86
    • jimmycodesocial