1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-27 12:11:23 +00:00
Files
.vscode
assets
components
config
framework
bigcommerce
commerce
local
saleor
shopify
swell
api
auth
cart
customer
product
types
utils
customer-token.ts
get-categories.ts
get-checkout-id.ts
get-search-variables.ts
get-sort-variables.ts
get-vendors.ts
handle-fetch-response.ts
handle-login.ts
index.ts
normalize.ts
storage.ts
wishlist
.env.template
commerce.config.json
const.ts
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
types.ts
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
jsconfig.json
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
swell-js.d.ts
tailwind.config.js
tsconfig.js
tsconfig.json
yarn.lock
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