40 lines
917 B
TypeScript
40 lines
917 B
TypeScript
import axios from "axios";
|
|
import type { Pod } from "~/classes/Pod";
|
|
|
|
export function getPods(namespace: string | undefined, onSuccess: (pods: Pod[]) => void)
|
|
{
|
|
axios.get<Pod[]>(useRuntimeConfig().public.apiBase + '/pods', {
|
|
headers: {
|
|
Authorization: "Bearer " + requireToken()
|
|
},
|
|
params: getParams(namespace)
|
|
})
|
|
.then((response) => {
|
|
onSuccess(response.data);
|
|
})
|
|
.catch();
|
|
}
|
|
|
|
export function deletePod(id: string | undefined, onSuccess: () => void)
|
|
{
|
|
axios.delete(useRuntimeConfig().public.apiBase + '/pods/' + id, {
|
|
headers: {
|
|
Authorization: "Bearer " + requireToken()
|
|
}
|
|
})
|
|
.then(() => {
|
|
onSuccess();
|
|
})
|
|
.catch();
|
|
}
|
|
|
|
function getParams(namespace: string | undefined)
|
|
{
|
|
if(namespace != undefined)
|
|
{
|
|
return {
|
|
namespace: namespace
|
|
}
|
|
}
|
|
return undefined;
|
|
} |