This mainly depends on its usage and the purpose of the component. Usually, the newly created lifecycle hook is normally the best for placing an API call. This is because, at this stage, the reactivity features and component data are available to operate despite the fact that the components haven’t rendered yet.
11. How can query parameters be fetched in Vue.js?
Normally, according to the docs of route objects, the $route from the components have to be accessed.
That will lead you to what you need, which is;
//from your component
console.log(this.$route.query.test) // outputs 'yay'
Posted Date:- 2021-09-07 22:46:27