Full-Stack Web Development with Vue.js and Node

(singke) #1

Building the Real Application Chapter 5


rating(newVal) { state.note = newVal; },
},
template: `
<div class="rating">
How was your experience getting help with this issues?
<star-rating v-model="rating" :show-rating="false"></star-rating>
</div>`,
components: { 'star-rating': StarRating },
});

const component = new RatingComponent().$mount(wrapper);

export default {
name: 'Movie',
data() {
return {
movie: [],
};
},
mounted() {
this.fetchMovie();
},
methods: {
async rate() {
this.$swal({
content: component.$el,
buttons: {
confirm: {
value: 0,
},
},
}).then(() => {
const movieId = this.$route.params.id;
return axios({
method: 'post',
data: {
rate: state.note,
},
url: `http://localhost:8081/movies/rate/${movieId}`,
headers: {
'Content-Type': 'application/json',
},
})
.then(() => {
this.$swal(`Thank you for rating! ${state.note}`, 'success');
})
.catch((error) => {
const message = error.response.data.message;
Free download pdf