From 22cbaec879cf54325f6e81485b02ed8ad9aceaaa Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Thu, 23 Apr 2020 00:36:47 +0200 Subject: [PATCH] Done --- frontend/pages/create.vue | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/frontend/pages/create.vue b/frontend/pages/create.vue index a309136..d433f14 100644 --- a/frontend/pages/create.vue +++ b/frontend/pages/create.vue @@ -9,10 +9,12 @@ Create a note + + A note with the same title already exists + @@ -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) + }) } }