request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.76k stars 297 forks source link

Get request object #293

Closed xxluke closed 5 years ago

xxluke commented 5 years ago

Is it possible to get the actual request object, like I would get if I used http.request?

I want to use it for debugging reasons, I'm trying to get the curl command by using the request-as-curl or request-to-curl package.

analog-nico commented 5 years ago

Yes. Use the resolveWithFullResponse: true parameter to get the full response object (IncomingMessage) and then use response.req which is the request object (ClientRequest). Here is an example of how to use the resolveWithFullResponse parameter: https://github.com/request/request-promise#get-the-full-response-instead-of-just-the-body