Registry / http-networking / request-promise-core

request-promise-core

JSON →
library1.1.4jsnpmunverified

request-promise-core is a foundational library that provides Promise support for the now-deprecated 'request' HTTP client. It is not intended for direct use by most applications; instead, it serves as the core logic for higher-level packages like `request-promise`, `request-promise-any`, `request-promise-bluebird`, and `request-promise-native`. Published last on July 22, 2020, this package's development has ceased, mirroring the abandonment of its peer dependency, 'request'. It offers a mechanism to inject Promise capabilities (e.g., `.then()`, `.catch()`) into the `request` object via a `configure` function, requiring a compatible Promise implementation to be explicitly passed. Due to the deprecation of its upstream 'request' dependency, this package is considered obsolete and should not be used in new projects.

npm install request-promise-core
INSTALL
IMPORT
SIG · REQUEST-PROMISE-CO
R
request-promise-core
http-networkingjavascriptv1.1.4
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.

configure
const configure = require('request-promise-core/configure/request2');
import configure from 'request-promise-core/configure/request2';
This package primarily uses CommonJS `require` syntax. The 'configure' function is the main entry point to add Promise capabilities to a 'request' instance.
stealthyRequire
const stealthyRequire = require('stealthy-require');
import stealthyRequire from 'stealthy-require';
Used in the recommended pattern to safely load and patch the 'request' library without interfering with other 'request' consumers in the same application. This is a CommonJS module.
request
const request = stealthyRequire(require.cache, function () { return require('request'); });
const request = require('request');
Directly `require('request')` before patching can lead to issues if other parts of the application also use 'request'. The `stealthy-require` pattern is recommended to ensure the Promise-enhanced version is used consistently.

This quickstart demonstrates how to apply Promise capabilities to the 'request' library using `request-promise-core`, including safe loading with `stealthy-require` and basic error handling.

const stealthyRequire = require('stealthy-require'); const request = stealthyRequire(require.cache, function () { return require('request'); }); const configure = require('request-promise-core/configure/request2'); configure({ request: request, PromiseImpl: Promise, expose: [ 'then', 'catch', 'promise' ], constructorMixin: function (resolve, reject) { // `this` is the request object } }); // 3. Use request with its promise capabilities request('https://api.example.com/data') .then(function (body) { console.log('Received data:', body.substring(0, 100) + '...'); }) .catch(function (err) { console.error('Request failed:', err.message); }); // Example with environment variable for a real API call (mocked here) const API_KEY = process.env.EXAMPLE_API_KEY ?? 'MOCK_API_KEY'; request(`https://api.example.com/secure-data?key=${API_KEY}`) .then(function (body) { console.log('Secure data access successful (mocked):', body.substring(0, 100) + '...'); }) .catch(function (err) { console.error('Secure data access failed (mocked):', err.message); });
Debug
Known issues
breakingThe underlying 'request' library, which this package extends, was officially deprecated on February 11, 2020. This means 'request-promise-core' and its dependents (like 'request-promise') are also effectively abandoned and should not be used in new projects. Consider migrating to modern alternatives like Axios, `node-fetch`, or `undici`.
fix
Migrate away from 'request-promise-core' and the 'request' ecosystem entirely. Recommended alternatives include Axios, `node-fetch`, or the built-in `fetch` API in Node.js >= 18.
affects: >=1.0.0
gotchaDirectly using `require('request')` before patching its prototype with `request-promise-core` can lead to an unpatched 'request' instance being used by other parts of your application. The README explicitly recommends using `stealthy-require` to prevent such conflicts.
fix
Always load `request` via `stealthy-require` as shown in the package's usage example to ensure a consistent, patched instance across your application: `const request = stealthyRequire(require.cache, () => require('request'));`
affects: >=1.0.0
deprecatedThe 'request@next' branch for the 'request' library never fully materialized or reached a stable release. Consequently, the configuration helper `require('request-promise-core/configure/request-next')` is obsolete and should not be used.
fix
Avoid using `request-promise-core/configure/request-next`. Stick to `request-promise-core/configure/request2` for compatibility with `request@^2.34`, though migration away from the entire ecosystem is strongly advised.
affects: >=1.0.0
gotchaThis library is explicitly designed as a core component for other `request-promise` packages and is 'only recommended to use this library directly, if you have very specific requirements.' Most users should have used `request-promise` directly, which itself is now deprecated.
fix
If encountering this package as a direct dependency, reassess the need. It's almost certainly part of a deprecated chain. Migrate to a modern HTTP client.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'request'
The 'request' package is defined as a peer dependency, meaning it must be installed separately by the consumer project, but it was not.
fix
Install the 'request' package: `npm install --save request`.
TypeError: request(...).then is not a function
The 'request' instance was not properly patched by `request-promise-core`, or an unpatched 'request' instance was used. This often happens if `require('request')` is called directly before `request-promise-core` has a chance to apply its patches.
fix
Ensure `request-promise-core`'s `configure` function is called to patch `request`, and that `request` is loaded using `stealthyRequire` as recommended in the documentation to avoid using an unpatched instance.
TypeError: PromiseImpl must be a thenable constructor
The `PromiseImpl` option passed to the `configure` function was either missing or not a valid ES6-compatible Promise constructor.
fix
Ensure `PromiseImpl: Promise` (for native Promises) or a specific Promise library constructor (e.g., `PromiseImpl: Bluebird`) is provided to the `configure` function.
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies
requestrequiredCore HTTP client that this package extends with Promise capabilities. It is a peer dependency and must be installed separately.
stealthy-requirerequiredUsed in the recommended usage pattern to avoid patching an already-loaded 'request' instance, preventing conflicts if 'request' is used elsewhere without Promise support.
Agent activity
9 hits · last 30 days
node
8
Resources