From d184ffa564b3b4f2e60f141e693efe4e659bc6ef Mon Sep 17 00:00:00 2001 From: Fabian Vogler Date: Thu, 10 Oct 2024 20:51:53 +0200 Subject: [PATCH] Add default empty stationboard response --- lib/Transport/Application.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Transport/Application.php b/lib/Transport/Application.php index 2b9770e..a7755b1 100644 --- a/lib/Transport/Application.php +++ b/lib/Transport/Application.php @@ -477,7 +477,6 @@ public function __construct() * ) */ $app->get('/v1/stationboard', function (Request $request) use ($app) { - $stationboard = []; $limit = $request->get('limit', 40); if ($limit > 420) { @@ -511,6 +510,13 @@ public function __construct() $query->maxJourneys = $limit; $stationboard = $app['api']->getStationBoard($query); + } else { + + // default empty response + $stationboard = [ + 'station' => null, + 'stationboard' => [], + ]; } $json = $app['serializer']->serialize((object) $stationboard, 'json');