import { useStore } from '../useStore' export default async function fetcher( input: RequestInfo, init: RequestInit = {} ): Promise { const { token } = useStore.getState() const headers = { ...init.headers } as Record if (token) { headers.Authorization = `Bearer ${token}` } const credentials = 'include' as RequestCredentials const res = await fetch(input, { ...init, credentials, headers }) return res.json() }