diff --git a/src/lib/devices/DeviceCard/DeviceRoutes.svelte b/src/lib/devices/DeviceCard/DeviceRoutes.svelte index 59f606f..2168ba2 100644 --- a/src/lib/devices/DeviceCard/DeviceRoutes.svelte +++ b/src/lib/devices/DeviceCard/DeviceRoutes.svelte @@ -1,5 +1,5 @@ Device Routes diff --git a/src/lib/devices/DeviceCard/DeviceRoutesAPI.svelte b/src/lib/devices/DeviceCard/DeviceRoutesAPI.svelte index f43d34c..09f09c8 100644 --- a/src/lib/devices/DeviceCard/DeviceRoutesAPI.svelte +++ b/src/lib/devices/DeviceCard/DeviceRoutesAPI.svelte @@ -80,4 +80,30 @@ throw error; }); } + + export async function deleteDeviceRoute(routeID: number): Promise { + // variables in local storage + let headscaleURL = localStorage.getItem('headscaleURL') || ''; + let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; + let endpointURL = `/api/v1/routes/${routeID}`; + + await fetch(headscaleURL + endpointURL, { + method: 'DELETE', + headers: { + Accept: 'application/json', + Authorization: `Bearer ${headscaleAPIKey}` + } + }) + .then((response) => { + if (response.ok) { + } else { + return response.text().then((text) => { + throw JSON.parse(text).message; + }); + } + }) + .catch((error) => { + throw error; + }); + }