UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

22 lines (21 loc) 722 B
import { redirectToProxy as n } from "@scalar/oas-utils/helpers"; import { PROXY_URL as i, UPLOAD_TEMP_API_URL as s } from "../../consts/urls.js"; function p(e) { return !!e && typeof e == "object" && "url" in e && typeof e.url == "string"; } async function f(e) { const t = JSON.stringify({ document: e }), r = await fetch(n(i, s), { method: "POST", headers: { "Content-Type": "application/json" }, body: t }); if (!r.ok) throw new Error(` Failed to generate temporary link, server responded with ${r.status}`); const o = await r.json(); if (!p(o)) throw new Error("Failed to generate temporary link, invalid response from server"); return o.url; } export { f as uploadTempDocument };