request-debug is a Node.js utility library designed to monitor and debug HTTP(S) requests made by the now-deprecated `request` module. It provides an easy way to intercept and log request headers, bodies (for POST), response headers, response bodies (if a callback is provided to `request`), redirects, and authentication challenges. The current stable version is 0.2.0, and due to its dependency on the unmaintained `request` library, its release cadence is effectively none, making it an abandoned project. Its key differentiator was its tight integration with `request`, patching the module instance directly to emit detailed event data for each request lifecycle stage, either to stderr or via a user-defined callback function.
npm install request-debugVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to enable `request-debug` and make a sample HTTP request with basic authentication to an external service (`httpbin.org`), showing how the debug events are logged to the console (stderr by default). It includes a commented-out custom handler example.
Migrate to modern HTTP clients like `node-fetch`, `axios`, or Node.js's built-in `http`/`https` modules, and use their respective debugging or interceptor mechanisms. This library should not be used in new projects.
Always use `const requestDebug = require('request-debug');` to import the module.Ensure `request-debug` is initialized and attached to the `request` instance before attempting to call `request.stopDebugging()`.
When using `request-debug` to inspect response bodies, ensure that the `request` call includes a callback function to buffer the response. Alternatively, consider using the stream `data` events directly on the `request` object for debugging streamed responses.
Install the `request` module: `npm install request`
Ensure you are using `require('request-debug')(request);` (CommonJS syntax) and that the `request` module instance is correctly passed as the first argument.Initialize `request-debug` with `require('request-debug')(request);` before attempting to call `request.stopDebugging()`.