From 28829301679be9cdd83f32b584b5d633559a76a0 Mon Sep 17 00:00:00 2001 From: Guillaume Mercey Date: Wed, 15 Jun 2022 17:18:28 -0700 Subject: [PATCH] Properly handle errors in FeathersVuexGet --- .../src/components/FeathersVuexGet.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/feathers-vuex-commons/src/components/FeathersVuexGet.ts b/packages/feathers-vuex-commons/src/components/FeathersVuexGet.ts index 130ef02c..c7a4d05e 100644 --- a/packages/feathers-vuex-commons/src/components/FeathersVuexGet.ts +++ b/packages/feathers-vuex-commons/src/components/FeathersVuexGet.ts @@ -98,8 +98,8 @@ export default { }, }, data: () => ({ - isFindPending: false, isGetPending: false, + error: null }), computed: { item() { @@ -120,8 +120,8 @@ export default { } }, scope() { - const { item, isGetPending } = this - const defaultScope = { item, isGetPending } + const { item, isGetPending, error } = this + const defaultScope = { item, isGetPending, error } return this.editScope(defaultScope) || defaultScope }, @@ -149,9 +149,14 @@ export default { return this.$store .dispatch(`${this.service}/get`, getArgs.length === 1 ? this.id : getArgs) .then(response => { - this.isGetPending = false return response }) + .catch(error => { + this.error = error + }) + .finally(() => { + this.isGetPending = false + }) } } },