frontend/requests/services.ts
2025-11-06 15:02:04 +01:00

27 lines
664 B
TypeScript

import axios, { type AxiosRequestConfig } from "axios";
import type { Service } from "~/classes/Service";
export function getServices(namespace: string | undefined, onSuccess: (services: Service[]) => void)
{
axios.get<Service[]>(ApiConfig.getHttpBase() + '/services', {
headers: {
Authorization: "Bearer " + requireToken()
},
params: getParams(namespace)
})
.then(response => {
onSuccess(response.data);
})
.catch();
}
function getParams(namespace: string | undefined)
{
if(namespace != undefined)
{
return {
namespace: namespace
}
}
return undefined;
}