19 lines
585 B
JavaScript
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);
|
|
};
|
|
};
|