admin管理员组

文章数量:1391929

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

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

Share Improve this question asked Apr 17, 2018 at 9:44 Kotov AleksandrKotov Aleksandr 331 silver badge3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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

axios.get('/user', {
    params: {
      ID: 12345
    }
  });

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);

本文标签: javascriptPassing parameters in get query to vue jsStack Overflow