From 95ceca6530dde45f54696def7b20e0154ab69f1d Mon Sep 17 00:00:00 2001 From: Guillaume Mercey Date: Tue, 7 Jun 2022 14:39:12 -0700 Subject: [PATCH 1/2] Properly handle errors in FeathersVuexGet Catch dispatch exceptions and expose the error to the scope --- src/FeathersVuexGet.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/FeathersVuexGet.ts b/src/FeathersVuexGet.ts index e41339c7..3986b87a 100644 --- a/src/FeathersVuexGet.ts +++ b/src/FeathersVuexGet.ts @@ -87,8 +87,8 @@ export default { } }, data: () => ({ - isFindPending: false, - isGetPending: false + isGetPending: false, + error: null }), computed: { item() { @@ -109,8 +109,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 } @@ -145,9 +145,14 @@ export default { getArgs.length === 1 ? this.id : getArgs ) .then(response => { - this.isGetPending = false return response }) + .catch(error => { + this.error = error + }) + .finally(() => { + this.isGetPending = false + } } } }, From de09fe15fe47cf756e9d77656af2d5c510a0f38e Mon Sep 17 00:00:00 2001 From: Guillaume Mercey Date: Tue, 7 Jun 2022 14:46:53 -0700 Subject: [PATCH 2/2] FIX missing closing parentheses --- src/FeathersVuexGet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FeathersVuexGet.ts b/src/FeathersVuexGet.ts index 3986b87a..d9d5f883 100644 --- a/src/FeathersVuexGet.ts +++ b/src/FeathersVuexGet.ts @@ -152,7 +152,7 @@ export default { }) .finally(() => { this.isGetPending = false - } + }) } } },