class JsonJumble { constructor(user) { this.user = user; } async get(key) { const dataEndpoint = `https://jsonjumble.com/v1/data`; const result = await fetch(`${dataEndpoint}/${this.user}/${key}`, { method: "GET", mode: "cors", cache: "no-cache", credentials: "same-origin", headers: { "Content-Type": "application/json", }, redirect: "follow", referrerPolicy: "no-referrer", }); if (result.status == 200) { return await result.json() } else { throw new Exception(`${result.status} ${result.statusText}: Retrieving ${dataEndpoint}/${this.user}/${key} was not successful.`) } } }