1

I'm pretty new to Vue / Axios.

What I'm trying to do is send the query string through to an email using Axios. The Query string is set from Google Adwords.

http://website.co.uk/page.php?keyword=jh%20page&gclid=XXIaIZobFhEInb6zoDyH3AIViwDTCh1yawIPFYTAYASRAEgIJH_D_BwE

My current vue code

const app = new Vue({
    el: '#app',
    data() {
        return {
            step: 1,
            counter: 0,
            tagName: null,
            debt: {
                name: null,
                email: null,
                tel: null
            }
        }
    },
    methods: {
        prev() {
            this.step--;
        },
        next() {
            this.step++;
        },
        submit() {
            axios.post('post.php', {
                'name': this.debt.name,
                'email': this.debt.email,
                'tel': this.debt.tel
            }).then(response => {
                console.log('success', response.data.message)
            }).catch(error => {
                console.log(error.response)
            });
        }
    }
});

Hopefully, someone can help push me in the right direction. Please let me know if you need any other information.

Thanks, J.

2
  • what error are you getting? Commented Jul 4, 2018 at 15:05
  • Why not just sending name,email,tel,querystring Commented Jul 4, 2018 at 16:39

1 Answer 1

4

If you are asking how to set a query string with axios it is set in the request config as params.

axios.request('/post.php', {
  method: 'post',
  params: {
    test: '321',
  },
});
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, What im looking to do it get the Query String from the URL and then send it to an email using Axios. Do you know how I would do that?
There are a number of ways to parse the query string, one way is to use URLSearchParams

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.