Destructure more things

This commit is contained in:
Oliver Davies 2019-06-05 12:06:00 +01:00
parent 726a0b535f
commit a4b018204d

View file

@ -81,11 +81,11 @@ export default {
'Content-Type': 'application/vnd.api+json' 'Content-Type': 'application/vnd.api+json'
} }
}) })
.then(({ data }) => { .then(({ data: { data } }) => {
const title = data.data.attributes.title const title = data.attributes.title
this.messages.push(`Session ${title} has been created.`) this.messages.push(`Session ${title} has been created.`)
this.$emit('submitted', data.data) this.$emit('submitted', data)
this.form.body = '' this.form.body = ''
this.form.title = '' this.form.title = ''
@ -93,8 +93,8 @@ export default {
this.errors = [] this.errors = []
this.messages = [] this.messages = []
}) })
.catch(error => { .catch(({ response: { data } }) => {
this.errors = _(error.response.data.errors).map('detail').value() this.errors = _(data.errors).map('detail').value()
}) })
} }
} }