{"library":"request-debug","title":"request-debug","description":"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.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install request-debug"],"cli":null},"imports":["const requestDebug = require('request-debug');","require('request-debug')(request);","require('request-debug')(request, function(type, data, r) { console.log(type, data); });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const request = require('request');\nconst util = require('util');\n\n// Enable request-debug, sending output to stderr by default\nrequire('request-debug')(request);\n\n// Alternatively, provide a custom handler function:\n// require('request-debug')(request, function(type, data, r) {\n//   console.error(`[${type.toUpperCase()}] debugId: ${data.debugId}`);\n//   console.error(util.inspect(data, { colors: true, depth: 3 }));\n// });\n\nconsole.log('Making a debuggable HTTP request...');\n\nrequest({\n    uri  : 'https://httpbin.org/digest-auth/auth/user/pass',\n    auth : {\n        user : 'user',\n        pass : 'pass',\n        sendImmediately : false\n    },\n    // IMPORTANT: rejectUnauthorized is only for example purposes to ignore self-signed certs\n    // Do NOT use in production with untrusted certs.\n    rejectUnauthorized : process.env.NODE_ENV !== 'production' ? false : true,\n    headers: {\n        'User-Agent': 'request-debug-example'\n    }\n}, function(err, res, body) {\n    if (err) {\n        console.error('Request failed:', err.message);\n    } else {\n        console.log('REQUEST RESULTS:');\n        console.log('  Status Code:', res.statusCode);\n        console.log('  Body:', body.substring(0, 100) + '...');\n    }\n    // Stop debugging once the process is complete (optional)\n    if (request.stopDebugging) {\n        request.stopDebugging();\n    }\n});\n","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}