From e2cd4128c690418c857ec5802339817ecac99600 Mon Sep 17 00:00:00 2001 From: cond0r Date: Thu, 13 May 2021 09:35:31 +0300 Subject: [PATCH] Update use-customer.tsx --- framework/shopify/customer/use-customer.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/framework/shopify/customer/use-customer.tsx b/framework/shopify/customer/use-customer.tsx index 137f0da74..7b600838e 100644 --- a/framework/shopify/customer/use-customer.tsx +++ b/framework/shopify/customer/use-customer.tsx @@ -10,11 +10,15 @@ export const handler: SWRHook = { query: getCustomerQuery, }, async fetcher({ options, fetch }) { - const data = await fetch({ - ...options, - variables: { customerAccessToken: getCustomerToken() }, - }) - return data.customer ?? null + const customerAccessToken = getCustomerToken() + if (customerAccessToken) { + const data = await fetch({ + ...options, + variables: { customerAccessToken: getCustomerToken() }, + }) + return data.customer + } + return null }, useHook: ({ useData }) => (input) => { return useData({