INNER CODE UNIT · TypeScript

readResponseJson

caura-ai/caura · clients/typescript/src/index.ts:310

async function readResponseJson(res: Response): Promise<any> {
  try {
    return await res.json();
  } catch (cause) {
    if (cause instanceof SyntaxError) throw cause;
    throw new TransportError(cause);
  }
}

async function raiseForStatus(res: Response): Promise<void> {
  if (res.ok) return;
  let payload: any = {};
  try {
    payload = await readResponseJson(res);
  } catch (cause) {
    if (!(cause instanceof SyntaxError)) throw cause;
    payload = {};
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…