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

Support .finally(...) #30

Open KamasamaK opened 5 years ago

KamasamaK commented 5 years ago

Promise.prototype.finally is introduced in ES2018, but the README indicates that it is "not available".

ainthek commented 5 years ago

+1

tbjgolden commented 5 years ago

This nearly stopped me from using this library 😬

Thanks @KamasamaK for confirming

tbjgolden commented 5 years ago

added a pr: https://github.com/request/request-promise-native/pull/46

analog-nico commented 5 years ago

I just merged @tbjgolden ’s PR #46 which clarifies this. With node v10 and above you can write these:

rp(...)
    .then(...)
    .catch(...)
    .finally(...)
rp(...)
    .catch(...)
    .finally(...)
rp(...)
    .then(...)
    .finally(...)

But not:

rp(...)
    .finally(...)

Until the direct finally call is supported, you can use:

rp(...).promise()
    .finally(...)

I leave this issue open until that last case without using .promise() is supported as well.