From a59a41edab9b586bcfc2c7359bea7ba414d4c0d3 Mon Sep 17 00:00:00 2001 From: gkielwasser Date: Thu, 23 Sep 2021 02:37:39 +0200 Subject: [PATCH] Vendure - Fetcher - Globally throw errors (#391) * Vendure - Fetcher - Globally throw errors Globally throw errors from the Vendure fetcher when we detect errors in the response body * Remove unnecessary new function * Remove unnecessary import Co-authored-by: Luis Alvarez D --- framework/vendure/fetcher.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/vendure/fetcher.ts b/framework/vendure/fetcher.ts index bf8f0dcd8..26e1eec28 100644 --- a/framework/vendure/fetcher.ts +++ b/framework/vendure/fetcher.ts @@ -41,11 +41,13 @@ export const fetcher: Fetcher = async ({ headers, credentials: 'include', }) - if (res.ok) { - const { data } = await res.json() + const { data, errors } = await res.json() + if (errors) { + throw await new FetcherError({ status: res.status, errors }) + } return data } - + throw await getError(res) }