Postman-request is a maintained fork of the popular, now-abandoned `request` module, specifically developed and used internally by Postman Runtime. Currently at version 2.88.1-postman.48, it does not follow a typical open-source release cadence but is updated as needed for Postman's internal applications. This package provides a simplified API for making HTTP requests, addressing numerous long-standing bugs and adding specific features that were never incorporated into the original `request` project. Key differentiators include fixes for old-style deflate responses, correct URL parameter encoding, enhanced redirect behaviors (especially for 307/308 with Host headers), `content-length` for streaming, improved form-data exception handling, and features like retaining authorization headers on cross-domain redirects and support for extending root CA certificates. It aims to offer a stable and patched alternative for projects still reliant on the `request` API.
npm install postman-requestVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic GET request to Google, logging the error, status code, and response body length.
Review existing `request` calls against `postman-request`'s specific bug fixes and added features. Test thoroughly to ensure compatibility, especially for edge cases in HTTP handling.
Prefer `require()` for consistency. If strict ESM is needed, investigate dynamic `import()` or build tool configurations. For new projects, consider modern Promise-based HTTP clients like `axios` or `node-fetch`.
Attach `.on('error', handler)` directly to the `request` call before any `.pipe()` operations to ensure proper error capture for upstream failures.For new application development not specifically tied to the original `request` API, modern HTTP clients (e.g., `node-fetch`, `axios`) offer more contemporary APIs and features.
Ensure environments have up-to-date root CA certificates. For custom CAs, use the `ca` option to provide trusted certificates. Avoid disabling SSL validation (`strictSSL: false` or `rejectUnauthorized: false`) in production due to security risks.
Ensure your system's root CA certificates are up-to-date. For private/self-signed CAs, pass the certificate authority via the `ca` option in the request configuration. Avoid `strictSSL: false` for security.
Use `const request = require('postman-request');` for CommonJS environments, which is the module's primary export pattern.Ensure your callback function only handles a single invocation. While `postman-request` aims to fix common `request` issues, robust error handling with flags can prevent double invocation: `let called = false; if (!called) { called = true; /* ...handle response... */ }`No dependency data recorded yet.