- 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
34 lines
738 B
JavaScript
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();
|
|
},
|
|
}
|