export function fetchApi(pathcomponents, query) { query.pretty = true; let url = '/api/' + pathcomponents.join("/") + "?" + new URLSearchParams(query).toString(); return fetch(url).then(response => { if (!response.ok) { throw new Error("Fetching api failed"); } return response; }).then(response => response.json()); } export function fetchLocations(query) { return fetchApi(["locations"], { query: query, addresses: false, poi: false, subStop: false, entrances: false, linesOfStops: false, }); } export function fetchJourneys(from_, to) { return fetchApi(["journeys"], { from: from_, to: to, }); }