mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 12:11:23 +00:00
.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
20 lines
343 B
TypeScript
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
|