0

How can I pass query paramenters using Axios such that I can get the query in my backend code using req.query.email. This doesn't seem to work:

this.$http.post(this.$BASE_URL + 'agents/auth/create-password', {
  data: { password: this.password },
  params: {
    email,
  },
})
.then((res) => {
  console.log(res);
})
.catch((error) => {
  console.log(error);
})

What I'm getting from my api is req.body.data and req.body.params.

5
  • Based on this.$http I don't think you are using axios instead you are using vue-resource. Please read github.com/pagekit/vue-resource/blob/master/docs/http.md. Commented Jul 17, 2020 at 10:31
  • I'm using axios, just using a prototype I set in my main.js Commented Jul 17, 2020 at 10:46
  • Sorry for the urgent conclusion. Could you post more code about that implementation? Since maybe there is something wrong about parameters. Commented Jul 17, 2020 at 10:50
  • What additional implementation do you ned to know? I explained what I want to do above Commented Jul 17, 2020 at 11:08
  • I want to know about how you implement this.$http which wrap axios or you just use Vue.prototype.$http = axios? Commented Jul 17, 2020 at 11:18

1 Answer 1

1
const querystring = require('querystring');
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));

For more information have a look on https://github.com/axios/axios#query-string.

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.