1
0
mirror of https://github.com/vercel/commerce.git synced 2025-03-18 00:12:33 +00:00
commerce/framework/swell/utils/handle-fetch-response.ts
2021-05-01 12:13:43 -05:00

20 lines
343 B
TypeScript

import { CommerceError } from '@commerce/utils/errors'
type SwellFetchResponse = {
error: {
message: string
code?: string
}
}
const handleFetchResponse = async (res: SwellFetchResponse) => {
if (res) {
if (res.error) {
throw new CommerceError(res.error)
}
return res
}
}
export default handleFetchResponse