Done
This commit is contained in:
parent
74aeb711f0
commit
22cbaec879
@ -9,10 +9,12 @@
|
||||
<v-toolbar-title>Create a note</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
|
||||
<v-alert v-if="conflict" type="error">
|
||||
A note with the same title already exists
|
||||
</v-alert>
|
||||
|
||||
<v-form
|
||||
ref="form"
|
||||
v-model="valid"
|
||||
lazy-validation
|
||||
>
|
||||
<v-card-text>
|
||||
@ -54,24 +56,33 @@
|
||||
title: '',
|
||||
tags: []
|
||||
},
|
||||
possibleTags: []
|
||||
possibleTags: [],
|
||||
conflict: false
|
||||
}),
|
||||
methods: {
|
||||
createNote() {
|
||||
this.conflict = false
|
||||
this.$axios.post(`/notes/${this.form.title}`, {
|
||||
tags: this.form.tags
|
||||
}).then(data => {
|
||||
console.log(data)
|
||||
}).then(_ => {
|
||||
this.$router.push("/notes")
|
||||
}
|
||||
).catch(e => {
|
||||
console.log(e)
|
||||
if (e.response && e.response.status === 409) {
|
||||
this.conflict = true
|
||||
} else {
|
||||
console.log("??")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$axios.get("/tags")
|
||||
.then(e => console.log(e.data))
|
||||
.then(e => this.possibleTags = e.data)
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user