import axios, { AxiosRequestConfig } from 'axios'; import { makeHeader } from "@/core/lib/url"; // eslint-disable-next-line @typescript-eslint/no-explicit-any export async function* fetchPaginated(url: string, headers?: AxiosRequestConfig['headers']): AsyncGenerator { if (headers == null) { headers = makeHeader(); } while (true) { const response = await axios.get(url, { headers: headers }); const data = response.data; yield data.results; url = data.next; if (!url) { break; } } }