简体   繁体   English

根据 url 示例,axios 的参数应该如何

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

I have this URL.我有这个 URL。 How can I translate it into params for axios?如何将其转换为 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: {
        // ?
      },
    });

Usually simply by setting a property with a key and value.通常只需通过键和值设置属性即可。

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

In cases where the key contains special characters, which are not allowed for property keys in JS, you can set the key in quotation marks如果key包含特殊字符,JS中的property key是不允许的,可以在key中设置引号

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM