4
0
forked from crowetic/commerce
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