简体   繁体   中英

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

I have this URL. How can I translate it into params for 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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