diff --git a/frontend/src/routes/task/Index.svelte b/frontend/src/routes/task/Index.svelte index 91c0bd2..dc011a9 100644 --- a/frontend/src/routes/task/Index.svelte +++ b/frontend/src/routes/task/Index.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte'; import { useTinyRouter } from 'svelte-tiny-router'; - import { api } from '../../urls.svelte.js'; + import { api, get, patch } from '../../urls.svelte.js'; import { error, yikes } from '../../warn.svelte'; import { t } from '../../translations.svelte.js'; @@ -23,16 +23,10 @@ const prj = projects[task.project_id]; const stat = Object.keys(prj.allowed_states).find(k => prj.allowed_states[k] === state); const url = api(`task/${tid}`); - const resp = await fetch(url,{ - credentials : 'include', - method : 'PATCH', - body : JSON.stringify({status:stat}) - }); + const resp = await patch(url,{status:stat}); if (resp.ok){ tasks[idx] = await resp.json(); - } else { - error(resp); - } + } else error(resp); } function abort(idx){ @@ -66,17 +60,15 @@ async function loadProject(pid){ const url = api(`project/${pid}`); - const resp = await fetch(url,{credentials:'include'}); + const resp = await get(url); if (resp.ok){ projects[pid] = await resp.json(); - } else { - error(resp); - } + } else error(resp); } async function load(){ const url = api(`task?offset=${bounds.offset}&limit=${bounds.limit}`); - const resp = await fetch(url,{credentials:'include'}); + const resp = await get(url); if (resp.ok){ let newTasks = await resp.json(); if (bounds.offset == 0) { @@ -93,9 +85,7 @@ bounds.offset += bounds.limit; load(); } - } else { - error(resp); - } + } else error(resp); } function open(idx){ @@ -139,13 +129,14 @@