Hemmelig.app/client/api/settings.js
bjarneo 0c86efd56c
refactor: use fastify vite for the dev server (#284)
* refactor: use fastify vite for the server

by doing this we do not need to have local hacks for the routes. No local proxy needed. Everything just works.

* fix: update the dockerfile build path

* fix: update package.json

* fix: fonts path
2024-03-11 13:43:20 +01:00

42 lines
939 B
JavaScript

import config from '../config';
export const getSettings = async () => {
const data = await fetch(`${config.get('api.host')}/admin/settings`, {
method: 'GET',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
});
if (data.status === 401) {
return {
statusCode: 401,
};
}
return data.json();
};
export const updateSettings = async (data) => {
const response = await fetch(`${config.get('api.host')}/admin/settings`, {
method: 'PUT',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const json = await response.json();
if ([401, 403].includes(response.status) && !json.type) {
return {
statusCode: response.status,
error: json.error,
};
}
return json;
};