Full-Stack Web Development with Vue.js and Node

(singke) #1

Building the Real Application Chapter 5


release_year: '',
nameRules: [
(v) => !!v || 'Movie name is required'
],
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'
],
checkbox: false
}),
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: 'http://localhost:8081/movies',
headers: {
'Content-Type': 'application/json'
}
})
.then((response) => {
this.$router.push({ name: 'Home' });
this.$refs.form.reset();
})
.catch((error) => {
});
Free download pdf