1

I need to pass the array using vue http get. But I not sure how to do so.I know I can pass parameter for get method using (I am using spatie/laravel-query-builder) '/users?filter[name]=John'.

I have an array of category = [10, 20, 100]; the contain of category is id. I need to pass the id to laravel controller.

vue.js to call get

axios.get(url).then((res) => {
  console.log(res.data);
})
.catch((err) => console.error(err));
1

1 Answer 1

1

You need to JSON.stringify the passed data and assign this string to a get parameter (in this example: myArray).

const data = [{ id: 1 }, { id: 2 }]
const url = 'https://myendpoint.com'

axios.get(url, {
  params: {
    myArray: JSON.stringify(data)
  }
}).then(res => console.log(res))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.