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)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.