Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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: {
        // ?
      },
    });

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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" }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading