Public
Back
Version 5
8/14/2023
async function stopDepartures(globalStopId: string) {
const cached = me.stopDeparturesCache[globalStopId];
if (cached && Date.now() - cached.time < me.transitCacheExpiry) {
return cached.data;
}
const url =
`https://external.transitapp.com/v3/public/stop_departures?global_stop_id=${
encodeURIComponent(globalStopId)
}`;
const json = await stevekrouse.fetchJSON(url, {
headers: {
apiKey: me.secrets.transit,
},
});
console.log(json);
const data = json.route_departures;
me.stopDeparturesCache[globalStopId] = {
time: Date.now(),
data,
};
return data;
}
Updated: October 23, 2023