Use fetch and Request from node-fetch in Spree SDK

This commit is contained in:
tniezg
2021-08-18 10:39:30 +02:00
parent b38d15e1ee
commit 30c29f0da8
3 changed files with 23 additions and 16 deletions

View File

@@ -12,7 +12,7 @@ import { SpreeSdkVariables } from 'framework/spree/types'
import SpreeSdkMethodFromEndpointPathError from 'framework/spree/errors/SpreeSdkMethodFromEndpointPathError'
import { GraphQLFetcher, GraphQLFetcherResult } from '@commerce/api'
import createCreateFetchFetcher from '../../utils/createCreateFetchFetcher'
import createVercelFetch from '@vercel/fetch'
import fetch, { Request } from 'node-fetch'
const createApiFetch: (
getConfig: () => SpreeApiConfig
@@ -22,7 +22,10 @@ const createApiFetch: (
const client = makeClient({
host: requireConfigValue('spreeApiHost') as string,
fetcherType: 'custom',
createFetcher: createCreateFetchFetcher({ fetch: createVercelFetch() }),
createFetcher: createCreateFetchFetcher({
fetch,
requestClass: Request,
}),
})
return async (url, queryData = {}, fetchOptions = {}) => {