{"id":18425,"library":"http-as-promised","title":"http-as-promised","description":"A Node.js HTTP client that wraps the request library with Bluebird promises, automatically rejecting on HTTP error status codes (>= 400). Version 2.0.1 is the latest stable release (last updated 2016). The package is deprecated in favor of using modern HTTP clients like `node-fetch` or `axios` with native promises. Key differentiators: built-in HTTP error classes for specific status codes (e.g., `NotFoundError`, `InternalServerError`) and automatic rejection on non-2xx responses.","status":"deprecated","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/jcready/http-as-promised","tags":["javascript","errors","exceptions","throw","custom","util","utility","bluebird","promise"],"install":[{"cmd":"npm install http-as-promised","lang":"bash","label":"npm"},{"cmd":"yarn add http-as-promised","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-as-promised","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for promise implementation","package":"bluebird","optional":false},{"reason":"Used to create custom error constructors","package":"create-error","optional":false},{"reason":"The underlying HTTP library","package":"request","optional":false}],"imports":[{"note":"Package only supports CommonJS, not ESM","wrong":"import $http from 'http-as-promised'","symbol":"$http","correct":"var $http = require('http-as-promised')"},{"note":"Only CommonJS require is supported","wrong":"import { HTTPError } from 'http-as-promised'","symbol":"HTTPError","correct":"var HTTPError = require('http-as-promised').HTTPError"},{"note":"Specific status code errors are available as named exports on the main export","wrong":"","symbol":"HTTPError constructors (e.g., NotFoundError)","correct":"var NotFoundError = require('http-as-promised').NotFoundError"}],"quickstart":{"code":"var $http = require('http-as-promised');\n\n$http('https://api.github.com', { headers: { 'User-Agent': 'http-as-promised' } })\n  .spread(function (response, body) {\n    console.log('Status:', response.statusCode);\n    console.log('Body:', body);\n  })\n  .catch(function (err) {\n    console.error('Request failed:', err.message);\n  });","lang":"javascript","description":"Shows basic GET request with spread to access response and body, and catch for HTTP errors."},"warnings":[{"fix":"Use axios, node-fetch, or got instead","message":"Package is deprecated","severity":"deprecated","affected_versions":">=2.0.1"},{"fix":"Update to Node >=10 or use alternative HTTP client","message":"Requires Node >=4 (no longer maintained for modern versions)","severity":"breaking","affected_versions":">=2.0.1"},{"fix":"Use .spread() or set resolve option to 'body' if you only want the body","message":"Promise resolves with array [response, body] by default, not just body","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set error: false in options to handle 4xx/5xx responses yourself","message":"Automatically rejects for status codes >=400 unless error option is false","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a different HTTP client","message":"Request library is deprecated","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install http-as-promised` and use `require('http-as-promised')`","cause":"Package not installed or used with ESM import","error":"Error: Cannot find module 'http-as-promised'"},{"fix":"Ensure you call $http() and not use it as a static object","cause":"Forgetting to call $http as a function","error":"TypeError: $http(...).then is not a function"},{"fix":"Add .catch() or use try/catch with async/await","cause":"Request returned 404 and no catch handler","error":"Unhandled rejection: HTTPError: Not Found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}