Wegwichtel/public/js/api-client.js
Florian Zumpe 32f161483d
Some checks failed
Sonarqube Scanner / Build and analyze (push) Failing after 1m27s
simplify application and remove window references
2026-06-17 16:08:01 +02:00

12 lines
515 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)}`)
};
}(globalThis.Wegwichtel, globalThis.jQuery));