{"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.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install request-promise-core"],"cli":null},"imports":["const configure = require('request-promise-core/configure/request2');","const stealthyRequire = require('stealthy-require');","const request = stealthyRequire(require.cache, function () { return require('request'); });"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}