import axios, { type AxiosRequestConfig } from "axios"; import type { Service } from "~/classes/Service"; export function getServices(namespace: string | undefined, onSuccess: (services: Service[]) => void) { axios.get(useRuntimeConfig().public.apiBase + '/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; }