INNER CODE UNIT · TypeScript

api

Flaque/quirk · src/api/index.ts:4

function api(method: string, path: string, body?: any) {
  if (!path.startsWith("/")) {
    throw new Error(
      "Expected path to start with forward slash like '/foo' instead of 'foo'"
    );
  }

  const options = {
    method,
    headers: {
      "Content-Type": "application/json",
      authorization: `basic ${base64.encode("user:" + QUIRK_API_SECRET)}`,
    },
  };

  if (method === "post") {
    options["body"] = JSON.stringify(body);
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…