簡體   English   中英

根據 url 示例,axios 的參數應該如何

[英]How should the parameters for axios look like according to the url example

我有這個 URL。 如何將其轉換為 axios 的參數?

customer?$select[0]=id&$select[1]=firstName&$select[2]=lastName&$select[3]=email&$skip=0&$sort[createdAt]=-1&email=test@email.com

const { data } = await this.request({
      method: 'get',
      url: `/customer`,
      params: {
        // ?
      },
    });

通常只需通過鍵和值設置屬性即可。

params: { email: "test@test.com" }

如果key包含特殊字符,JS中的property key是不允許的,可以在key中設置引號

params: { "$select[1]": "firstSame" }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM