feat: fill pages
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 10m25s
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 10m25s
This commit is contained in:
37
frontend/app/composables/useApi.ts
Normal file
37
frontend/app/composables/useApi.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user