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
Invalid paramsSerializer
TS type
#5058
Comments
@pegiadise Just had same issue now, I found the To fix the error you need to do next: config.paramsSerializer = {
encode: (params) => qs.stringify(params, { arrayFormat: 'repeat' })
} |
@R3VoLuT1OneR First of all thanks for checking the issue. There is either a bug with this or some breaking changes that are not documented. Explaining by example: config.paramsSerializer = {
encode: (params) => {
console.log('params =>', params)
return qs.stringify(params, { arrayFormat: 'repeat' })
},
} As you can see, the |
Yes, the |
This is also affecting me. |
Affecting me as well, if it's possible to add native support for the same "array format: repeat" behavior it will be amazing! |
@RNR1 Axios already supports this out of the box. By default, Axios encodes arrays in "bracket" format but supports 3 qs formats except "comma".
So to encode in const {data} = await axios.get('https://postman-echo.com/get', {
params: {
a: ['b', 'c', 'd']
},
paramsSerializer: {
indexes: null // by default: false
}
}); Echo response:
|
is really helpful, it should be added to the official documentation |
To summarize, at time of writing (
|
Is there probably a difference with nested objects like qs gives:
Looks like axios adds an index even with
Or is there an error on my side? Edit: Just confirmed it, Axios adds an index in this case which I think it should't |
Created #5094 to track it. |
Relevant PR: #5113 |
worked. maybe because of outdated version |
Undocumented API change. Not cool. |
Shouldn't it be: paramsSerializer: {
serialize: (params) => {
return qs.stringify(params, { arrayFormat: 'repeat' })
}
} ? |
This makes total sense for me and worked in my case. |
Helped in my case. |
how do i fix this in my case? @babazookz @alete89 @dduft
error message: Type '(params: any) => string' has no properties in common with type 'ParamsSerializerOptions' |
paramsSerializer: {
serialize: (params) => {
return queryString.stringify({ params })
}
} |
Describe the bug
The TS interface for
paramsSerializer
key in theAxiosRequestConfig
is wrong / incomplete.To Reproduce
Try to add a custom
paramsSerializer
functionExpected behavior
I can add a custom
paramsSerializer
function without getting type errorsEnvironment
1.1.0
4.7.4
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: