3

I do the filtering, when I click on the apply filter, the query in the API flies away php-developer, says that the request should be get, not post how to pass parameters to the get query?

example for my post request

export const filterDate = (options) => {
    console.log(options)
    return axios.post(url, options).then(({ data }) => {
        if (data.errors) throw new Error(JSON.stringify(data.errors));
        return data;
    })
};

but if I just replace the post on the get parameters are not transferred

2 Answers 2

3

If you want to pass parameters in get request, pass an object with "params" property, as follow:

axios.get('/user', {
    params: {
      ID: 12345
    }
  });
Sign up to request clarification or add additional context in comments.

Comments

1

in options you specify a param object:

params: {
  k: val
},

or by building an UrlSearchParam object:

const params = new URLSearchParams();
params.append('k', 'val');
axios.get(url, params);

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.