request / request-promise-native

The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.
ISC License
1.1k stars 63 forks source link

Time request setting not returning info about the timing of the call #25

Closed jpgcode closed 5 years ago

jpgcode commented 6 years ago

In main request docs https://github.com/request/request there is an option called "time" that in case is set to true is supposed to add additional details about the time of the transaction:

time - if true, the request-response cycle (including all redirects) is timed at millisecond resolution. When set, the following properties are added to the response object ...

Adding the flag into my request options I do not get the information I need.

Here the code of my request:

const options = {
        url: '...',
        headers: '...',
        json: true,
        method:"GET",
        time: true,
        timeout: 5000
}

request(options)
        .then(response => {
              // --> Response object only returning the body of my request.
         }
davebachmann commented 6 years ago

HI, check out https://github.com/request/request-promise#get-the-full-response-instead-of-just-the-body

Once I set "resolveWithFullResponse: true" in the options, I am able to see the response object, include response.elapsedTime.

arichiardi commented 5 years ago

I am trying this as well but it does not seem to show up for me...@jpgcode did it work for you?

analog-nico commented 5 years ago

Correct! As @davebachmann explains above, use the resolveWithFullResponse: true option and you are good to go.