Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: make defaults chaining actually work (v9 regression) #144

Merged
merged 1 commit into from
May 9, 2022

Conversation

glasser
Copy link
Contributor

@glasser glasser commented Apr 29, 2022

The README says:

A defaulted fetch will also have a .defaults() method, so they can
be chained.

But this didn't really work, because while the defaults method was
placed on the defaulted fetch, a chained defaulted fetch would just
call the original fetch function directly instead of the intermediate
function.

This PR makes chaining actually work and adds a test.

Also, it fixes the previous test, which wasn't actually verifying that
the correct request headers were received because it used the nock API
incorrectly: the option is reqheaders not reqHeaders.

Note that this was a regression in v9.0.0; the equivalent line before the refactor grabbed this and called that instead. (We don't use that approach here because it doesn't work in an arrow function.)

The README says:

> A defaulted `fetch` will also have a `.defaults()` method, so they can
> be chained.

But this didn't really work, because while the `defaults` method was
placed on the `defaulted` fetch, a chained defaulted fetch would just
call the original fetch function directly instead of the intermediate
function.

This PR makes chaining actually work and adds a test.

Also, it fixes the previous test, which wasn't actually verifying that
the correct request headers were received because it used the nock API
incorrectly: the option is `reqheaders` not `reqHeaders`.
@glasser glasser requested a review from a team as a code owner April 29, 2022 17:56
@glasser glasser changed the title fix: make defaults chaining actually work fix: make defaults chaining actually work (v9 regression) Apr 29, 2022
@wraithgar wraithgar merged commit aa71e81 into npm:main May 9, 2022
@wraithgar
Copy link
Member

Thank you

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants