mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
20 lines
322 B
TypeScript
20 lines
322 B
TypeScript
import { Fetcher } from '@commerce/utils/types'
|
|
|
|
const shopApiUrl = '/data.json'
|
|
|
|
export const fetcher: Fetcher = async ({
|
|
url,
|
|
method = 'GET',
|
|
variables,
|
|
query,
|
|
body: bodyObj,
|
|
}) => {
|
|
const res = await fetch(shopApiUrl)
|
|
|
|
if (res.ok) {
|
|
const { data } = await res.json()
|
|
return data
|
|
}
|
|
throw res
|
|
}
|