-
-
Notifications
You must be signed in to change notification settings - Fork 942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default searchParams not properly merged when requesting searchParams is undefined #1610
Comments
Would you be able to submit a pull request with one or more failing tests? That would help to get this fixed faster. |
@sindresorhus Sorry for the late reply. I just found out that it seems to be working as intended referring to normalize-arguments.ts test. It seems the test intends to reset the searchParams by putting |
@asomethings It could be intended behavior, but I still don't like it as it's ambiguous. Anyway #1667 (merged, yay!) is much more stricter when providing options. In order to retain the previous options, simply omit them (or, if defined, use the Currently, only these options accept The following will reset those values:
In order to reset other options such as
Note that const createEmptyHooks = () => {
return {
init: [],
beforeRequest: [],
beforeError: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: []
};
};
// 1.
const secondInstance = instance.extend({mutableDefaults: true});
secondInstance.defaults.options.hooks = emptyHooks;
await secondInstance(...);
// 2.
await instance(..., {
hooks: {
init: [
(options, self) => {
self.hooks = createEmptyHooks();
}
]
}
}); We could implement |
Note that the above comment refers to the upcoming version of Got (12). |
Describe the bug
Actual behavior
Does not merge
searchParams
whensearchParams: undefined
making a request.But, sends default
searchParams
whenExpected behavior
Should pass default
searchParams
even though requestedsearchParams
is undefinedCode to reproduce
Checklist
The text was updated successfully, but these errors were encountered: