mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
Merge branch 'custom-checkout' of https://github.com/vercel/commerce into custom-checkout
This commit is contained in:
commit
f01ebc549f
@ -1,6 +1,6 @@
|
|||||||
import type { APIProvider, CommerceAPIConfig } from '@commerce/api'
|
import type { CommerceAPI, CommerceAPIConfig } from '@commerce/api'
|
||||||
import { CommerceAPI, getCommerceApi as commerceApi } from '@commerce/api'
|
import { getCommerceApi as commerceApi } from '@commerce/api'
|
||||||
import fetcher from './utils/fetch-local'
|
import createFetcher from './utils/fetch-local'
|
||||||
|
|
||||||
import getAllPages from './operations/get-all-pages'
|
import getAllPages from './operations/get-all-pages'
|
||||||
import getPage from './operations/get-page'
|
import getPage from './operations/get-page'
|
||||||
@ -17,7 +17,7 @@ const config: LocalConfig = {
|
|||||||
cartCookie: '',
|
cartCookie: '',
|
||||||
customerCookie: '',
|
customerCookie: '',
|
||||||
cartCookieMaxAge: 2592000,
|
cartCookieMaxAge: 2592000,
|
||||||
fetch: fetcher,
|
fetch: createFetcher(() => getCommerceApi().getConfig()),
|
||||||
}
|
}
|
||||||
|
|
||||||
const operations = {
|
const operations = {
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { FetcherError } from '@commerce/utils/errors'
|
import { FetcherError } from '@commerce/utils/errors'
|
||||||
import type { GraphQLFetcher } from '@commerce/api'
|
import type { GraphQLFetcher } from '@commerce/api'
|
||||||
import { getCommerceApi } from '../index'
|
import type { LocalConfig } from '../index'
|
||||||
import fetch from './fetch'
|
import fetch from './fetch'
|
||||||
|
|
||||||
const fetchGraphqlApi: GraphQLFetcher = async (
|
const fetchGraphqlApi: (getConfig: () => LocalConfig) => GraphQLFetcher =
|
||||||
query: string,
|
(getConfig) =>
|
||||||
{ variables, preview } = {},
|
async (query: string, { variables, preview } = {}, fetchOptions) => {
|
||||||
fetchOptions
|
const config = getConfig()
|
||||||
) => {
|
|
||||||
const config = getCommerceApi().getConfig()
|
|
||||||
const res = await fetch(config.commerceUrl, {
|
const res = await fetch(config.commerceUrl, {
|
||||||
...fetchOptions,
|
...fetchOptions,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user