From e3618ea641507cd70546c651e4ab3c2c7a2bab8e Mon Sep 17 00:00:00 2001 From: desmondlsl <68117020+desmondlsl@users.noreply.github.com> Date: Sun, 27 Oct 2024 01:05:14 +0800 Subject: [PATCH] lightRail should respect status field from API --- src/lightRail.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lightRail.ts b/src/lightRail.ts index 24d23af..7e57c53 100644 --- a/src/lightRail.ts +++ b/src/lightRail.ts @@ -21,8 +21,9 @@ export default function fetchEtas({ }, ) .then((response) => response.json()) - .then(({ platform_list }) => - platform_list.reduce( + .then(({ status, platform_list }) => { + if (status === 0) return []; + return platform_list.reduce( (acc: Eta[], { route_list, platform_id }: any) => [ ...acc, ...route_list @@ -74,8 +75,8 @@ export default function fetchEtas({ }, []), ], [], - ), - ) + ) + }) .catch((e) => { console.error(e); return [];