promised-http

raw JSON →
0.0.2 verified Sat Apr 25 auth: no javascript deprecated

Promised-http is an early, proof-of-concept HTTP library for Node.js that wraps the native `http` module with promises (specifically the `q` library). Version 0.0.2 is the latest and only release, with no updates since 2011. It predates modern promise patterns and ES6 Promises, making it obsolete. Key differentiators: one of the first promise-based HTTP clients, but now superseded by `axios`, `node-fetch`, and `got`. Not recommended for new projects.

error Error: Cannot find module 'q'
cause Missing peer dependency `q`. The package expects `q` to be installed separately.
fix
Run npm install q to install q as a dependency.
error TypeError: request(...).then is not a function
cause Mixing CJS `require` with ES6 promise usage incorrectly, or not using the correct import.
fix
Ensure you import using ES6 import syntax or correctly convert the q promise to native.
error ReferenceError: request is not defined
cause Trying to use `request` without importing it properly.
fix
Use import http from 'promised-http' and then call http.request(options).
deprecated Package is unmaintained since 2011. Use modern alternatives like `axios`, `node-fetch`, or `got`.
fix Replace with a maintained HTTP client library.
breaking Uses `q` promises, not ES6 Promises. Will not work with native `async/await` without conversion.
fix Convert `q` promises to native Promises using `Q()` or upgrade to a library with native promises.
gotcha The `request` function expects options in Node.js `http.request` format (e.g., `host`, `port`, `path`). Not compatible with URL strings.
fix Use the `http.request` options object; do not pass a URL string.
gotcha No built-in support for HTTPS. Requires separate handling or using Node's https module directly.
fix Use Node's `https` module or a modern library that handles both HTTP and HTTPS.
gotcha Module only works in Node.js, not in the browser. No browser build available.
fix Use an isomorphic library like `axios` or `fetch` for cross-platform support.
npm install promised-http
yarn add promised-http
pnpm add promised-http

Demonstrates basic GET request using the promise-based `request` function from promised-http. Note: The library is outdated and not recommended for production.

import http from 'promised-http';

const options = {
  host: 'api.example.com',
  path: '/data',
  method: 'GET'
};

http.request(options)
  .then(response => {
    console.log('Status:', response.statusCode);
    return response.body;
  })
  .then(body => console.log('Body:', body))
  .catch(err => console.error('Error:', err));