Files
phundrak.com/frontend/app/composables/useApi.ts
Lucien Cartier-Tilet fceeb5307c
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 10m25s
feat: fill pages
2025-11-12 04:46:21 +01:00

38 lines
799 B
TypeScript

export function useApi() {
const config = useRuntimeConfig();
const backend = config.public.apiBase;
const commonBaseOptions = { baseURL: backend };
const get = (endpoint, options = {}) =>
useFetch(endpoint, {
method: 'GET',
...commonBaseOptions,
...options,
});
const post = (endpoint, body, options = {}) =>
$fetch(endpoint, {
method: 'POST',
body,
...commonBaseOptions,
...options,
});
const put = (endpoint, body, options = {}) =>
$fetch(endpoint, {
body,
method: 'PUT',
...commonBaseOptions,
...options,
});
const del = (endpoint, options = {}) =>
$fetch(endpoint, {
method: 'DELETE',
...commonBaseOptions,
...options,
});
return { get, post, put, del };
}