mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 13:41:22 +00:00
* Changed to query page by id * Fixed page query, Changed use-search GraphQl query * Update use-search.tsx * remove unused util * Changed cookie expiration * Update tsconfig.json * Fix add to cart & prepare for user activation * Update helpers.ts * Update helpers.ts * Changes, fix Shopify GraphQL deprecations * Update checkout-to-cart.ts * Default to BigCommerce * Update index.ts * Fixed types
24 lines
521 B
TypeScript
24 lines
521 B
TypeScript
import { Fetcher } from '@commerce/utils/types'
|
|
import { API_TOKEN, API_URL } from './const'
|
|
import { handleFetchResponse } from './utils'
|
|
|
|
const fetcher: Fetcher = async ({
|
|
url = API_URL,
|
|
method = 'POST',
|
|
variables,
|
|
query,
|
|
}) => {
|
|
return handleFetchResponse(
|
|
await fetch(url, {
|
|
method,
|
|
body: JSON.stringify({ query, variables }),
|
|
headers: {
|
|
'X-Shopify-Storefront-Access-Token': API_TOKEN!,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
})
|
|
)
|
|
}
|
|
|
|
export default fetcher
|