{"id":17263,"library":"http-response-status-code","title":"HTTP Response Status Code Utilities","description":"This package, `http-response-status-code`, provides a lightweight and comprehensive utility for interacting with HTTP status codes, names, and descriptions. Currently at version 1.7.5, it offers a stable API for retrieving details, validating codes, and categorizing them into informational, success, redirection, client error, and server error groups. The library differentiates itself by providing a full suite of helper functions, such as `getStatusName`, `getStatusDescription`, `getNotFound`, and dedicated checks like `isInformationalCode` or `isClientErrorCode`, in addition to exposing all standard HTTP status codes as named exports. Its release cadence appears to be moderate, with minor updates focusing on feature additions like the \"Toolset Overview\" in 1.7.2 and continuous code hygiene improvements. It ships with TypeScript types, ensuring robust usage in modern JavaScript and TypeScript environments, making it a reliable choice for handling HTTP response logic.","status":"active","version":"1.7.5","language":"javascript","source_language":"en","source_url":"https://github.com/Skillnter/http-response-status-code","tags":["javascript","Http","Response","Status","Codes","Https","skillnter","typescript"],"install":[{"cmd":"npm install http-response-status-code","lang":"bash","label":"npm"},{"cmd":"yarn add http-response-status-code","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-response-status-code","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use this for CommonJS environments or to import all exports as a namespace in ESM.","wrong":"const STATUS_CODES = require('http-response-status-code');","symbol":"STATUS_CODES","correct":"import * as STATUS_CODES from 'http-response-status-code';"},{"note":"All individual status codes (e.g., OK, NOT_FOUND) and core utility functions are exported as named exports. This is the recommended ESM approach.","wrong":"import STATUS_CODES from 'http-response-status-code'; STATUS_CODES.OK;","symbol":"OK","correct":"import { OK, getStatusName, CODES } from 'http-response-status-code';"},{"note":"Be mindful of exact function names; typos can lead to runtime errors.","wrong":"import * as STATUS_CODES from 'http-response-status-code'; STATUS_CODES.getStatName(...);","symbol":"getStatusName","correct":"import { getStatusName } from 'http-response-status-code';"}],"quickstart":{"code":"import { OK, NOT_FOUND, isSuccessCode, getStatusName, getStatusDescription, getNotFound, getStatusCode, CLIENT_ERROR_CODES } from 'http-response-status-code';\n\nconsole.log('OK status code:', OK); // 200\nconsole.log('Not Found status code:', NOT_FOUND); // 404\n\nconst status200Name = getStatusName(OK);\nconsole.log('Name for 200:', status200Name); // OK\n\nconst status404Description = getStatusDescription(NOT_FOUND);\nconsole.log('Description for 404:', status404Description); // Not Found\n\nconst nameForNotFound = getNotFound().name;\nconsole.log('Name from getNotFound():', nameForNotFound); // Not Found\n\nconst codeForOK = getStatusCode('OK');\nconsole.log('Code for \"OK\":', codeForOK); // 200\n\nconsole.log('Is 200 a success code?', isSuccessCode(OK)); // true\nconsole.log('Is 404 a success code?', isSuccessCode(NOT_FOUND)); // false\n\nconsole.log('First 5 client error codes:', CLIENT_ERROR_CODES.slice(0, 5)); // [400, 401, 402, 403, 404]","lang":"typescript","description":"This example demonstrates how to import and use various utilities to retrieve status codes, names, descriptions, and check code categories."},"warnings":[{"fix":"Ensure you are calling the correct function, e.g., `STATUS_CODES.getStatusName(STATUS_CODES.OK)` or `STATUS_CODES.getStatusCode('OK')`.","message":"The release notes for v1.7.2 contain a typo in the `getStat` example, which is incomplete and incorrect. The correct function names are `getStatusName` or `getStatusCode`.","severity":"gotcha","affected_versions":">=1.7.2"},{"fix":"Avoid `import STATUS_CODES from 'pkg'` as a default import is not provided, which will result in `undefined`.","message":"When migrating from CommonJS `require` to ESM `import`, ensure you use named imports for specific codes and functions (e.g., `import { OK, getStatusName } from 'pkg'`) or a namespace import (`import * as STATUS_CODES from 'pkg'`) if you want to access all exports under a single object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use the exact upper-case string name as defined in HTTP standards, or refer to the library's `CODES` object for a definitive list.","message":"The library primarily uses full upper-case strings for status code names (e.g., 'OK', 'NOT FOUND') when functions like `getStatusCode` are expecting a string input. Mismatched casing might lead to unexpected results.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Correct the function call to `STATUS_CODES.getStatusName` or `STATUS_CODES.getStatusCode`.","cause":"Attempting to use a non-existent function name, possibly copied from an incomplete example in release notes.","error":"TypeError: STATUS_CODES.getStat is not a function"},{"fix":"Change your import statement to `import { OK } from 'http-response-status-code';` for specific codes or `import * as STATUS_CODES from 'http-response-status-code';` to access all exports via `STATUS_CODES.OK`.","cause":"Incorrect ESM import syntax, attempting to use a default import when only named or namespace imports are available.","error":"TypeError: Cannot read properties of undefined (reading 'OK')"}],"ecosystem":"npm","meta_description":null}