From a537249679cb6f05e53b33ce918e96e51530d7c5 Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Tue, 19 Nov 2024 00:45:44 +0200 Subject: [PATCH] feat: add server-side loading for stop schedule --- src/routes/stops/[stopID]/schedule/+page.server.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/routes/stops/[stopID]/schedule/+page.server.js diff --git a/src/routes/stops/[stopID]/schedule/+page.server.js b/src/routes/stops/[stopID]/schedule/+page.server.js new file mode 100644 index 0000000..843958c --- /dev/null +++ b/src/routes/stops/[stopID]/schedule/+page.server.js @@ -0,0 +1,12 @@ +import oba, { handleOBAResponse } from '$lib/obaSdk.js'; + +export async function load({ params }) { + const stopID = params.stopID; + const response = await oba.scheduleForStop.retrieve(stopID); + const scheduleForStop = await handleOBAResponse(response, 'stop').json(); + + return { + stopID: params.stopID, + scheduleForStop: scheduleForStop.data + }; +}