Wegwichtel/public/js/api-client.js
2026-06-17 00:10:46 +02:00

12 lines
507 B
JavaScript

(function (ns, $) {
'use strict';
function request(path) {
return $.ajax({ url: ns.Config.apiBase + path, method: 'GET', dataType: 'json', cache: false });
}
ns.Api = {
health: () => request('/health'),
routes: position => request('/routes' + (position ? `?lat=${encodeURIComponent(position.lat)}&lon=${encodeURIComponent(position.lon)}&radiusKm=${ns.Config.routeRadiusKm}` : '')),
route: id => request(`/routes/${encodeURIComponent(id)}`)
};
}(window.Wegwichtel, window.jQuery));