Describe the bug
We have a custom serialize method that is passed to axios by options.paramsSerializer.
It's work fine with axios@0.28.0, but from axios@0.28.1, it throw the error :
options must be an object
To Reproduce
No response
Code snippet
const conf = {
paramsSerializer: function (params: any) {
return qs.stringify(params, { arrayFormat: 'repeat' })
}
}
const instance = axios.create(conf)
instance.request()
Expected behavior
The HTTP request is executed (like in 0.28.0).
Axios Version
0.28.1
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
The problem come from the commit 111811eadc849c08a3a2074930c50f68afa6eba5.
In axios.js, this check was added :
if (paramsSerializer !== undefined) {
validator.assertOptions(paramsSerializer, {
encode: validators.function,
serialize: validators.function
}, true);
}
And validator.assertOptions throw the error when the first parameter isn't a object.
Moreover, the next line manage the case where paramsSerializer is a function :
utils.isFunction(paramsSerializer) && (config.paramsSerializer = {serialize: paramsSerializer});
A solution will be to down the check after the below line transform paramsSerializer from function to object, so the check will be ok.
Describe the bug
We have a custom serialize method that is passed to axios by
options.paramsSerializer.It's work fine with axios@0.28.0, but from axios@0.28.1, it throw the error :
To Reproduce
No response
Code snippet
Expected behavior
The HTTP request is executed (like in 0.28.0).
Axios Version
0.28.1
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
The problem come from the commit 111811eadc849c08a3a2074930c50f68afa6eba5.
In axios.js, this check was added :
And
validator.assertOptionsthrow the error when the first parameter isn't a object.Moreover, the next line manage the case where
paramsSerializeris a function :A solution will be to down the check after the below line transform
paramsSerializerfrom function to object, so the check will be ok.