Display trip details

This commit is contained in:
2025-06-19 01:19:24 +02:00
parent 1d4fc62668
commit 433157278d
4 changed files with 43 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
export function fetchApi(pathcomponents, query) {
console.log(pathcomponents);
query.pretty = true;
let url = '/api/' + pathcomponents.join("/") + "?" + new URLSearchParams(query).toString();
let url = '/api/' + pathcomponents.map(component => encodeURIComponent(component)).join("/") + "?" + new URLSearchParams(query).toString();
console.log(url);
return fetch(url).then(response => {
if (!response.ok) {
throw new Error("Fetching api failed");
@@ -26,3 +28,7 @@ export function fetchJourneys(from_, to) {
to: to,
});
}
export function fetchTrip(trip_id) {
return fetchApi(["trips", trip_id], {});
}