mirror of
https://github.com/vercel/commerce.git
synced 2025-07-03 19:51:22 +00:00
Adjust fetchers to the latest Spree SDK interface
This commit is contained in:
parent
a191e28df7
commit
3d2ee58c4d
@ -58,6 +58,7 @@ export default function getAllProductPathsOperation({
|
|||||||
const variables: SpreeSdkVariables = {
|
const variables: SpreeSdkVariables = {
|
||||||
methodPath: 'products.list',
|
methodPath: 'products.list',
|
||||||
arguments: [
|
arguments: [
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
fields: {
|
fields: {
|
||||||
product: 'slug',
|
product: 'slug',
|
||||||
|
@ -45,6 +45,7 @@ export default function getAllProductsOperation({
|
|||||||
const variables: SpreeSdkVariables = {
|
const variables: SpreeSdkVariables = {
|
||||||
methodPath: 'products.list',
|
methodPath: 'products.list',
|
||||||
arguments: [
|
arguments: [
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
include: 'variants,images,option_types,variants.option_values',
|
include: 'variants,images,option_types,variants.option_values',
|
||||||
per_page: first,
|
per_page: first,
|
||||||
|
@ -52,6 +52,7 @@ export default function getProductOperation({
|
|||||||
methodPath: 'products.show',
|
methodPath: 'products.show',
|
||||||
arguments: [
|
arguments: [
|
||||||
getProductVariables.slug,
|
getProductVariables.slug,
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
include: 'variants,images,option_types,variants.option_values',
|
include: 'variants,images,option_types,variants.option_values',
|
||||||
},
|
},
|
||||||
|
@ -46,6 +46,7 @@ export const handler: SWRHook<SearchProductsHook> = {
|
|||||||
variables: {
|
variables: {
|
||||||
methodPath: 'products.list',
|
methodPath: 'products.list',
|
||||||
arguments: [
|
arguments: [
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
include: 'variants,images,option_types,variants.option_values',
|
include: 'variants,images,option_types,variants.option_values',
|
||||||
per_page: 50,
|
per_page: 50,
|
||||||
|
@ -47,7 +47,6 @@ const createCustomizedFetchFetcher: CreateCustomizedFetchFetcher = (
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response: Response = await fetch(request)
|
const response: Response = await fetch(request)
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@ -61,11 +60,7 @@ const createCustomizedFetchFetcher: CreateCustomizedFetchFetcher = (
|
|||||||
data: Object.setPrototypeOf({ data }, { response }),
|
data: Object.setPrototypeOf({ data }, { response }),
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof TypeError) {
|
throw new FetchError(null, request, null, error.message)
|
||||||
throw new FetchError(null, request, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof FetchError) {
|
if (error instanceof FetchError) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user