PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 13, 2022

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

 October 13, 2022     axios, javascript, request, url     No comments   

Issue

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

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" }


Answered By - DaveExotic
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing