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:
parent
1720bd698c
commit
a59a41edab
@ -41,11 +41,13 @@ export const fetcher: Fetcher = async ({
|
|||||||
headers,
|
headers,
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.ok) {
|
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
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw await getError(res)
|
throw await getError(res)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user