import unfetch from 'isomorphic-unfetch' import retry from 'fetch-retry' const fetch = (input: RequestInfo, init?: RequestInit) => retry(unfetch, { retries: 3, retryDelay: 500, })(input, init) export const fetchAPI = async (input: RequestInfo, init?: RequestInit) => { const response = await fetch(input, init) if (response.ok) { return response.json() as Promise } console.error(await response.text()) throw new Error(`Error while fetching ${input}`) }