How to correctly use axios params with arrays

后端 未结 7 498
臣服心动
臣服心动 2021-02-01 14:55

How to add indexes to array in query string?

I tried send data like this:

axios.get(\'/myController/myAction\', { params: { storeIds: [1,2,3] })
<         


        
7条回答
  •  时光取名叫无心
    2021-02-01 14:59

    You can use paramsSerializer and serialize parameters with https://www.npmjs.com/package/qs

    axios.get('/myController/myAction', {
      params: {
        storeIds: [1,2,3]
      },
      paramsSerializer: params => {
        return qs.stringify(params)
      }
    })
    

提交回复
热议问题