Shorten code

This commit is contained in:
Fred Boniface 2023-06-17 01:56:05 +01:00
parent bf8dea7bcd
commit c2bc1ad1e5

View File

@ -13,7 +13,7 @@
fetchData();
}
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) {
if (jsonData?.GetStationBoardResult?.trainServices?.service ?? []) {
services = [...jsonData.GetStationBoardResult.trainServices.service];
} else {
services = ["No train services available"];