Registry / http-networking / http-as-promised

http-as-promised

JSON →
library2.0.1jsnpmunverified

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.

npm install http-as-promised
INSTALL
IMPORT
SIG · HTTP-AS-PROMISED
H
http-as-promised
http-networkingjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

$http
var $http = require('http-as-promised')
import $http from 'http-as-promised'
Package only supports CommonJS, not ESM
HTTPError
var HTTPError = require('http-as-promised').HTTPError
import { HTTPError } from 'http-as-promised'
Only CommonJS require is supported
HTTPError constructors (e.g., NotFoundError)
var NotFoundError = require('http-as-promised').NotFoundError
Specific status code errors are available as named exports on the main export

Shows basic GET request with spread to access response and body, and catch for HTTP errors.

var $http = require('http-as-promised'); $http('https://api.github.com', { headers: { 'User-Agent': 'http-as-promised' } }) .spread(function (response, body) { console.log('Status:', response.statusCode); console.log('Body:', body); }) .catch(function (err) { console.error('Request failed:', err.message); });
Debug
Known issues
deprecatedPackage is deprecated
fix
Use axios, node-fetch, or got instead
affects: >=2.0.1
breakingRequires Node >=4 (no longer maintained for modern versions)
fix
Update to Node >=10 or use alternative HTTP client
affects: >=2.0.1
gotchaPromise resolves with array [response, body] by default, not just body
fix
Use .spread() or set resolve option to 'body' if you only want the body
affects: >=1.0.0
gotchaAutomatically rejects for status codes >=400 unless error option is false
fix
Set error: false in options to handle 4xx/5xx responses yourself
affects: >=1.0.0
deprecatedRequest library is deprecated
fix
Use a different HTTP client
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'http-as-promised'
Package not installed or used with ESM import
fix
Run `npm install http-as-promised` and use `require('http-as-promised')`
TypeError: $http(...).then is not a function
Forgetting to call $http as a function
fix
Ensure you call $http() and not use it as a static object
Unhandled rejection: HTTPError: Not Found
Request returned 404 and no catch handler
fix
Add .catch() or use try/catch with async/await
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
bluebirdrequiredUsed for promise implementation
create-errorrequiredUsed to create custom error constructors
requestrequiredThe underlying HTTP library
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
http-as-promised — npm install http-as-promised · libregistry