forked from crowetic/commerce
use @zeit/fetch server-side
This commit is contained in:
parent
42ceab42e8
commit
f9ff967347
@ -1,7 +1,8 @@
|
|||||||
import { FetcherError } from '@lib/commerce/utils/errors'
|
import { FetcherError } from '@lib/commerce/utils/errors'
|
||||||
import type { GraphQLFetcher } from 'lib/commerce/api'
|
import type { GraphQLFetcher } from '@lib/commerce/api'
|
||||||
import { getConfig } from '..'
|
import { getConfig } from '..'
|
||||||
import log from '@lib/logger'
|
import log from '@lib/logger'
|
||||||
|
import fetch from '@lib/fetch'
|
||||||
|
|
||||||
const fetchGraphqlApi: GraphQLFetcher = async (
|
const fetchGraphqlApi: GraphQLFetcher = async (
|
||||||
query: string,
|
query: string,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getConfig } from '..'
|
import { getConfig } from '..'
|
||||||
import { BigcommerceApiError, BigcommerceNetworkError } from './errors'
|
import { BigcommerceApiError, BigcommerceNetworkError } from './errors'
|
||||||
|
import fetch from '@lib/fetch'
|
||||||
|
|
||||||
export default async function fetchStoreApi<T>(
|
export default async function fetchStoreApi<T>(
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
|
3
lib/fetch.ts
Normal file
3
lib/fetch.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import zeitFetch from '@zeit/fetch'
|
||||||
|
|
||||||
|
export default typeof window === 'undefined' ? zeitFetch() : fetch
|
Loading…
x
Reference in New Issue
Block a user