async function loadLogsForRoute()

in cdslogviewer/frontend/app/data-loading.ts [5:21]


async function loadLogsForRoute(
  routeName: string,
  cb: (newData: LogInfo) => void
) {
  const response = await authenticatedFetch(`/api/${routeName}`, {});
  const stream = await ndjsonStream(response.body);
  const reader = stream.getReader();

  while (true) {
    const nextResult = await reader.read();
    if (nextResult.done) {
      return;
    }

    cb(nextResult.value as LogInfo);
  }
}