4
0
forked from crowetic/commerce

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 <luis@vercel.com>
This commit is contained in:
gkielwasser 2021-09-23 02:37:39 +02:00 committed by GitHub
parent 1720bd698c
commit a59a41edab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}