{"id":16520,"library":"request-promise-core","title":"Request Promise Core","description":"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.","status":"abandoned","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/request/promise-core","tags":["javascript","xhr","http","https","promise","request","then","thenable","core"],"install":[{"cmd":"npm install request-promise-core","lang":"bash","label":"npm"},{"cmd":"yarn add request-promise-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add request-promise-core","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTTP client that this package extends with Promise capabilities. It is a peer dependency and must be installed separately.","package":"request","optional":false},{"reason":"Used in the recommended usage pattern to avoid patching an already-loaded 'request' instance, preventing conflicts if 'request' is used elsewhere without Promise support.","package":"stealthy-require","optional":false}],"imports":[{"note":"This package primarily uses CommonJS `require` syntax. The 'configure' function is the main entry point to add Promise capabilities to a 'request' instance.","wrong":"import configure from 'request-promise-core/configure/request2';","symbol":"configure","correct":"const configure = require('request-promise-core/configure/request2');"},{"note":"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.","wrong":"import stealthyRequire from 'stealthy-require';","symbol":"stealthyRequire","correct":"const stealthyRequire = require('stealthy-require');"},{"note":"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.","wrong":"const request = require('request');","symbol":"request","correct":"const request = stealthyRequire(require.cache, function () { return require('request'); });"}],"quickstart":{"code":"const stealthyRequire = require('stealthy-require');\nconst request = stealthyRequire(require.cache, function () {\n    return require('request');\n});\n\nconst configure = require('request-promise-core/configure/request2');\n\nconfigure({\n    request: request,\n    PromiseImpl: Promise,\n    expose: [\n        'then',\n        'catch',\n        'promise'\n    ],\n    constructorMixin: function (resolve, reject) {\n        // `this` is the request object\n    }\n});\n\n// 3. Use request with its promise capabilities\n\nrequest('https://api.example.com/data')\n    .then(function (body) {\n        console.log('Received data:', body.substring(0, 100) + '...');\n    })\n    .catch(function (err) {\n        console.error('Request failed:', err.message);\n    });\n\n// Example with environment variable for a real API call (mocked here)\nconst API_KEY = process.env.EXAMPLE_API_KEY ?? 'MOCK_API_KEY';\nrequest(`https://api.example.com/secure-data?key=${API_KEY}`)\n    .then(function (body) {\n        console.log('Secure data access successful (mocked):', body.substring(0, 100) + '...');\n    })\n    .catch(function (err) {\n        console.error('Secure data access failed (mocked):', err.message);\n    });","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The 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`.","severity":"breaking","affected_versions":">=1.0.0"},{"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'));`","message":"Directly 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The '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.","severity":"deprecated","affected_versions":">=1.0.0"},{"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.","message":"This 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.","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":"Install the 'request' package: `npm install --save request`.","cause":"The 'request' package is defined as a peer dependency, meaning it must be installed separately by the consumer project, but it was not.","error":"Error: Cannot find module 'request'"},{"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.","cause":"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.","error":"TypeError: request(...).then is not a function"},{"fix":"Ensure `PromiseImpl: Promise` (for native Promises) or a specific Promise library constructor (e.g., `PromiseImpl: Bluebird`) is provided to the `configure` function.","cause":"The `PromiseImpl` option passed to the `configure` function was either missing or not a valid ES6-compatible Promise constructor.","error":"TypeError: PromiseImpl must be a thenable constructor"}],"ecosystem":"npm"}