最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Correct way of using Axios paramsSerializer in its version 1.x - Stack Overflow

programmeradmin4浏览0评论

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: 'ma', 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?

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: 'ma', 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?

Share Improve this question asked Oct 11, 2022 at 9:02 AlexAlex 1,0462 gold badges15 silver badges31 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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

Hope you find it useful

发布评论

评论列表(0)

  1. 暂无评论