import { api_url } from '/js/settings.js'; const _get = async (route) => { const res = await fetch(await api_url(route)); return await res.json(); // const mime_type = res.headers.get('content-type').split(";")[0].trim(); // if(!mime_type) return; // return }; const _post = async (route, data) => await fetch(await api_url(route), { method: 'POST', headers: { "Content-Type": "application/json" }, body: typeof data === 'string' ? data : JSON.stringify(data) }); const _delete = async (route) => await fetch(await api_url(route), { method: 'DELETE' }) export const actions = { get_all() { return _get('actions') } } export const downloads = { create(download_url, preset_id) { return _post('download', { url: download_url, preset_id, }) } } export const notifications = { get_all() { return _get('notifications'); }, remove() { return _delete(`notifications/${notification_id}`); }, remove_all() { return _delete('notifications/inactive'); }, get_active() { return _get('notifications/active'); }, get_failed() { return _get('notifications/failed'); }, get_succeeded() { return _get('notifications/succeeded'); }, }