0👍
Have you considered to put your id as a computed prop?
If you leave it in the component data, it will just update on create the component, and you can remove the watcher over $route, what is a higher operation than a computed property.
data(){
return {
user: {},
thoughts: {},
}
},
methods:{
viewProfile() {
// You can use destructuring here over your response
axios.get('user_profile/' + this.id).then(({ data: { user_data, thoughts } }) => {
this.user = user_data;
this.thoughts = thoughts;
}).catch(() => {
});
},
computed: {
id() {
return this.$route.params.id;
}
},
// because of the vue lifecycle hooks, this should be a `mounted` hook intead of a `created`
mounted() {
this.viewProfile();
}
- [Vuejs]-Array Input saves as static Word 'Array' in SQL
- [Vuejs]-Vue.js: When implementing the "Simple State Management from Scratch" approach, how to pass on/access the store?
0👍
sorry for the trouble mates i fixed the issue by changing some routes configurations. Really thankful for your efforts.There was a collision between my web routes and the vue routes which was solved.
- [Vuejs]-How to change the default typography in vuetify?
- [Vuejs]-Can't close custom modal that is based on a-modal
Source:stackexchange.com