Full-Stack Web Development with Vue.js and Node

(singke) #1
Testing an MEVN Application Chapter 9

this.fetchUser();
this.listenToEvents();
},
methods: {
listenToEvents() {
bus.$on('refreshUser', () => {
this.fetchUser();
});
},
async fetchUser() {
return axios({
method: 'get',
url: '/api/current_user',
})
.then((response) => {
this.current_user = response.data.current_user;
})
.catch(() => {
});
},
logout() {
return axios({
method: 'get',
url: '/api/logout',
})
.then(() => {
bus.$emit('refreshUser');
this.$router.push({ name: 'Home' });
})
.catch(() => {
});
},
},
};
</script>

Also, let's update the id in AddMovie.vue:


<template>
<v-form v-model="valid" ref="form" lazy-validation>
<v-text-field
label="Movie Name"
v-model="name"
:rules="nameRules"
id="name"
required
></v-text-field>
<v-text-field
Free download pdf