Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way of using Axios paramsSerializer in its version 1.x

Axios has recently done a major upgrade and starting by its version 1.x I am unable to correctly introduce my own parameter serializer to it.

I used to do it as follows:

axios.defaults.paramsSerializer = params => qs.stringify(params, { arrayFormat: 'comma', encode: false });

Now the definition of paramsSerializer is changed to the following:

axios.defaults.paramsSerializer = {
    indexes: null,
    encode: ...
}

Does anyone know how I can assign my serializer to it considering the new definition?

like image 922
Ali Avatar asked Sep 03 '25 09:09

Ali


1 Answers

I was facing the same issue, and this comment helps me a lot https://github.com/axios/axios/issues/5058#issuecomment-1272107602

Hope you find it useful

like image 106
Alx Rodav Avatar answered Sep 05 '25 01:09

Alx Rodav