Divide fetcher with rest and graphql

This commit is contained in:
goncy
2021-08-25 19:51:15 -03:00
parent d4adfd079f
commit 5d76337f9e
16 changed files with 69 additions and 94 deletions

View File

@@ -23,13 +23,12 @@ export default function getSiteInfoOperation({
preview?: boolean
} = {}): Promise<T['data']> {
// Get fetch from the config
const { fetch } = commerce.getConfig(config)
const { storeRestFetch } = commerce.getConfig(config)
// Get list of categories
const rawCategories: RawCategory[] = await fetch<{ Items: RawCategory[] }>(
'GET',
`/me/categories`
).then((response) => response.Items)
const rawCategories: RawCategory[] = await storeRestFetch<{
Items: RawCategory[]
}>('GET', `/me/categories`).then((response) => response.Items)
return {
// Normalize categories