mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Fix build errors
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
import { Fetcher } from '@commerce/utils/types'
|
||||
import { handleFetchResponse } from './utils'
|
||||
import { swellConfig } from './index'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
|
||||
const fetcher: Fetcher = async ({ method = 'get', variables, query }) => {
|
||||
const { swell } = swellConfig
|
||||
|
||||
async function callSwell() {
|
||||
if (Array.isArray(variables)) {
|
||||
const arg1 = variables[0]
|
||||
const arg2 = variables[1]
|
||||
const response = await swell[query][method](arg1, arg2)
|
||||
const response = await swell[query!][method](arg1, arg2)
|
||||
return handleFetchResponse(response)
|
||||
} else {
|
||||
const response = await swell[query][method](variables)
|
||||
const response = await swell[query!][method](variables)
|
||||
return handleFetchResponse(response)
|
||||
}
|
||||
}
|
||||
if (query in swell) {
|
||||
|
||||
if (query && query in swell) {
|
||||
return await callSwell()
|
||||
} else {
|
||||
throw new CommerceError({ message: 'Invalid query argument!' })
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user