Update use-customer.tsx

This commit is contained in:
cond0r 2021-05-13 09:35:31 +03:00
parent 894c6a5a3f
commit e2cd4128c6

View File

@ -10,11 +10,15 @@ export const handler: SWRHook<Customer | null> = {
query: getCustomerQuery,
},
async fetcher({ options, fetch }) {
const data = await fetch<any | null>({
...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({