Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

How can I fetch query parameters in vue.js?

http:://somesite.com?test=yay

Can't find a way to fetch or do I need to use pure JS or some library for this?

share|improve this question
1  
Possible duplicate of How can I get query string values in JavaScript? – Joe Clay Mar 10 '16 at 10:45
    
Why is this getting down voted? I need it for Vue.js. If there is some vue library or something built in it would be preferred over raw js. – Rob Mar 10 '16 at 10:54
    
There's probably something in Vue Router that does it, if you're using that. – Joe Clay Mar 10 '16 at 10:58
3  
There is not even close to a duplicate. vue.js is a framework with a specific logic, different from vanila javascript – Yerko Palma Mar 10 '16 at 12:10
up vote 7 down vote accepted

According to the docs of route object, you have access to a $route object from your components, that expose what you need. In this case

//from your component
console.log(this.$route.query.test) // outputs 'yay'
share|improve this answer
    
Yup! If he is not using vue-router than this would indeed be a duplicate, as he will need to use standard JS methods. – Jeff Mar 10 '16 at 15:40
    
I just assume that because the same user posted just before a question about vue-router, I would create the vue-router tag if I had the reputation to do that – Yerko Palma Mar 10 '16 at 15:45
1  
good point! I went ahead and created the vue-router tag and added it. – Jeff Mar 10 '16 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.