import { getToken } from "./apolloClient" ; async function getDataSetWithKey ( key ) { const response = await fetch ( `${ process . env . NEXT_PUBLIC_DATASET_API }/${ key }` , { headers : { Authorization : await getToken ( ) } } ) ; return await response . text ( ) ; } export default async function getCSVFromCache ( name ) { const dsListItem = globalThis . dataSetsList . find ( ( ds ) => ds . name === name ) ; if ( dsListItem ) { const dsCache = globalThis . datasetCache [ name ] ; if ( dsCache ) return dsCache ; const fetchedData = await getDataSetWithKey ( dsListItem . key ) ; globalThis . datasetCache [ name ] = fetchedData ; return fetchedData ; } else { return undefined ; } }