Files
webdl/www/api.js
Tomas 49be7a313b Added simple gui, bugfixes, error logging
- Removed large promise from Download, and turned it into a sole trigger
- Fixed a nasty bug that threw unresolved promises
- Added error callback for IDownload
2026-01-10 05:23:35 +01:00

34 lines
738 B
JavaScript

API = {
__get: async function(url)
{
const res = await fetch(url);
if (res.status != 200)
throw new Error(await res.json().error);
return res;
},
getDownload: async function(id)
{
const res = await this.__get("/api/download/"+id);
return await res.json();
},
getErrors: async function()
{
const res = await this.__get("/api/errors");
return await res.json();
},
getDownloads: async function()
{
const res = await this.__get("/api/downloads");
return await res.json();
},
getQueue: async function()
{
const res = await this.__get("/api/queue");
return await res.json();
},
}