Axios get in url works but with second parameter as object it doesn't
Solution 1:
axios.get
accepts a request config as the second parameter (not query string params).
You can use the params
config option to set query string params as follows:
axios.get('/api', {
params: {
foo: 'bar'
}
});
Solution 2:
On client:
axios.get('/api', {
params: {
foo: 'bar',
},
});
On server:
function get(req, res, next) {
let param = req.query.foo
// ...
}