Files
thetool/public/mobile/shared/api.js
2026-01-17 12:48:08 +00:00

19 lines
585 B
JavaScript

export function createModuleApi(modulePath) {
return {
get: (endpoint) => fetch(`/MobileApp/${modulePath}/${endpoint}`).then(r => r.json()),
post: (endpoint, data) => fetch(`/MobileApp/${modulePath}/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
}).then(r => r.json())
};
}
export const debounce = (fn, delay) => {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => fn(...args), delay);
};
};