Full-Stack Web Development with Vue.js and Node

(singke) #1

Building Authentication with passport.js Chapter 6


],
genreRules: [
v => !!v || 'Movie genre year is required',
v => (v && v.length <= 80) || 'Genre must be less than equal to
80 characters.',
],
releaseRules: [
v => !!v || 'Movie release year is required',
],
select: null,
years: [
'2018',
'2017',
'2016',
'2015',
],
}),
methods: {
submit() {
if (this.$refs.form.validate()) {
return axios({
method: 'post',
data: {
name: this.name,
description: this.description,
release_year: this.release_year,
genre: this.genre,
},
url: '/movies',
headers: {
'Content-Type': 'application/json',
},
})
.then(() => {
this.$swal(
'Great!',
'Movie added successfully!',
'success',
);
this.$router.push({ name: 'Home' });
this.$refs.form.reset();
})
.catch(() => {
this.$swal(
'Oh oo!',
'Could not add the movie!',
'error',
);
Free download pdf