mrkeyoor.com_
Sat 08 Aug 22:00 UTC
npmWeb Backendupdated 08 Aug 2026

request-promise-core

request-promise-core is the internal adapter that adds Promise behavior to the old request HTTP client. It patches request's Request prototype, replaces each request callback with plumbing that resolves or rejects a chosen Promise implementation, and defines errors for transport failures, non-2xx status codes, and transform failures. It is not a standalone HTTP client, and its own README tells normal application developers to use a request-promise wrapper instead of configuring this package directly.

Verdict

Do not install request-promise-core for new code. Keep it only when maintaining a custom wrapper around request 2.x, and plan migration at the HTTP-client boundary rather than building more prototype patches on top.

API stability4/5The public configuration shape is small and has not moved since version 1.1.4 was released on 2020-07-22: request, PromiseImpl, expose, and constructorMixin still drive the adapter. That calm comes from inactivity, not active compatibility work, and the implementation reaches into request.Request.prototype.init, an internal surface that would be fragile with any substantially different request implementation.
Docs3/5The README gives a complete direct-configuration example, explains why stealthy-require may be necessary, names the request peer dependency, and documents both request 2.x and the abandoned request-next path. It does not provide a reference for options such as simple, resolveWithFullResponse, transform, or transform2xxOnly; understanding those behaviors requires reading lib/plumbing.js or the wrapper projects.
Maintenance1/5The latest npm release, 1.1.4, was published in July 2020, and GitHub reports the repository's last push on 2021-05-21. The repository is not formally archived, but the package exists to extend request, whose main repository is archived. The last changelog entries were lodash security bumps rather than forward development, so compatibility with new runtimes is largely accidental.
Ecosystem2/5The npm downloads endpoint reports 4,429,055 downloads in its last-week window, evidence that many dependency trees still contain this package. Direct community gravity is much smaller: GitHub reports 20 stars, the README positions it as core code for wrapper packages, and the request-promise family is tied to the discontinued request stack rather than current Node HTTP tooling.

Use it if

  • You maintain a legacy request-promise wrapper and need the same callback, transform, and error behavior as request-promise-core 1.1.4
  • You must provide a custom Promise implementation while preserving request 2.x options and request object methods
  • You are repairing an existing integration that imports configure/request2 and changing HTTP clients is outside the current scope
Skip it if

Setup reality

Installing this package alone is not enough. Version 1.1.4 declares request ^2.34 as a peer dependency, so a working legacy setup needs both npm install request and npm install request-promise-core. The README also recommends stealthy-require when application code or another dependency may load plain request, because configuration patches request.Request.prototype and a shared cached copy can unexpectedly gain then, catch, and promise methods. You must import configure/request2, pass the request function, provide a real Promise constructor, and list every Promise method to expose. The list cannot be empty and must contain then or configuration throws immediately. The patch is process-wide for that request module instance, so configure it once during startup rather than per call. Non-2xx responses reject by default because simple defaults to true; set simple: false if status codes are data. The resolved value is the body unless resolveWithFullResponse is true, while HEAD resolves to headers by default. There are no bundled TypeScript declarations, no ESM entry point, and no browser-specific build. The published code supports very old Node versions and CommonJS, but that compatibility also means the interface predates AbortController, native fetch, modern package exports, and current observability conventions. Treat it as containment work for a legacy request stack, not a foundation to add today.

Patterns

Install the core and its required HTTP clientinstall-peer-dependency

npm install request request-promise-core

request is a peer dependency, not a bundled runtime dependency. Installing only request-promise-core leaves the adapter with nothing to patch.

Add native Promise methods to requestconfigure-native-promises

const request = require('request');
const configure = require('request-promise-core/configure/request2');

configure({
  request,
  PromiseImpl: Promise,
  expose: ['then', 'catch', 'promise'],
});

Configuration mutates request.Request.prototype. Run it once during process startup, and include then in expose or the configurator throws.

Load an isolated request copy before patchingisolate-patched-request

const stealthyRequire = require('stealthy-require');
const request = stealthyRequire(require.cache, () => require('request'));
const configure = require('request-promise-core/configure/request2');

configure({ request, PromiseImpl: Promise, expose: ['then', 'catch', 'promise'] });

The README recommends isolation when other code expects an unmodified cached request export. stealthy-require must be installed separately.

Resolve a GET request to its bodyget-response-body

request({
  method: 'GET',
  uri: 'https://api.example.com/items',
  json: true,
}).then((body) => {
  console.log(body);
});

The default resolved value is body, and non-2xx responses reject because simple defaults to true.

Send and receive JSONpost-json

const created = await request({
  method: 'POST',
  uri: 'https://api.example.com/items',
  body: { name: 'paper clips' },
  json: true,
});

These are request 2.x options. request-promise-core only changes completion handling; serialization and transport still belong to request.

Resolve with status and headersread-full-response

const response = await request({
  uri: 'https://api.example.com/items/42',
  resolveWithFullResponse: true,
});

console.log(response.statusCode, response.headers, response.body);

Without resolveWithFullResponse: true, successful calls resolve only to the body.

Treat non-2xx responses as normal resultsaccept-error-status

const response = await request({
  uri: 'https://api.example.com/maybe-missing',
  simple: false,
  resolveWithFullResponse: true,
});

if (response.statusCode === 404) console.log('not found');

simple: false disables StatusCodeError rejection. Network failures can still reject with RequestError.

Inspect a rejected HTTP statushandle-status-error

try {
  await request({ uri: 'https://api.example.com/private', json: true });
} catch (error) {
  if (error.name === 'StatusCodeError') {
    console.error(error.statusCode, error.error);
  } else {
    throw error;
  }
}

StatusCodeError.error holds the response body, while response is the response object unless a transform changed the stored value.

Distinguish transport failureshandle-network-error

request({ uri: 'https://api.example.com/items', timeout: 5000 })
  .catch((error) => {
    if (error.name === 'RequestError') {
      console.error('transport failed', error.cause);
      return;
    }
    throw error;
  });

The original transport error is available as both cause and the legacy error property. Timeout behavior comes from request.

Transform a successful body before resolutiontransform-success-body

const names = await request({
  uri: 'https://api.example.com/items',
  json: true,
  transform(body) {
    return body.items.map((item) => item.name);
  },
  transform2xxOnly: true,
});

A thrown or rejected transform becomes TransformError. transform2xxOnly avoids transforming an error response before StatusCodeError is created.

Get the underlying Promise instanceunwrap-promise

const pendingRequest = request('https://api.example.com/items');
const bodyPromise = pendingRequest.promise();

bodyPromise.then(console.log);

promise() exists only if promise was included in expose. The request object remains abortable through request's own methods.

Issue a HEAD requestread-head-headers

const headers = await request({
  method: 'HEAD',
  uri: 'https://example.com/archive.zip',
});

console.log(headers['content-length']);

HEAD has a built-in default transform: it resolves to response.headers, or to the full response when resolveWithFullResponse is true.

Alternatives

PackageRegistryPick it when
gotnpmNode applications that want a maintained Promise-first HTTP client with retries, hooks, and modern cancellation
undicinpmNode applications that want the HTTP client and fetch implementation maintained alongside Node.js
axiosnpmTeams that need one Promise-based client API across Node and browsers, especially for interceptors