// Node.js, on your server. const base_url = "https://scormbox.com/api/v1"; const authorization = "Basic " + Buffer.from( process.env.SCORMBOX_API_KEY + ":" + process.env.SCORMBOX_API_SECRET ).toString("base64"); async function request(path, method = "GET", body) { const response = await fetch(base_url + path, { method, headers: { Authorization: authorization, "Content-Type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body) }); const result = await response.json(); if (!response.ok) throw new Error(result.error); return result; }