From 4bf77e6b00052638832cacf021579fe5f74ad5ff Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Thu, 12 Dec 2024 15:00:26 -0800 Subject: [PATCH] Check banner object for field before trying to iterate over it. (#840) --- src/data/queries/banners.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/data/queries/banners.ts b/src/data/queries/banners.ts index c0841355e..043c17841 100644 --- a/src/data/queries/banners.ts +++ b/src/data/queries/banners.ts @@ -62,15 +62,15 @@ export const formatter: QueryFormatter = (entities) => { path: banner.path?.alias, findFacilities: banner.field_alert_find_facilities_cta, // Normalizes banner alert data as it can come from api as a single object or array - bannerAlertVamcs: [] - .concat(banner.field_banner_alert_vamcs) - .map((vamc) => ({ - id: vamc.target_id, - path: vamc.url, - office: { - path: vamc.office?.url || null, - }, - })), + bannerAlertVamcs: banner.field_banner_alert_vamcs + ? [].concat(banner.field_banner_alert_vamcs).map((vamc) => ({ + id: vamc.target_id, + path: vamc.url, + office: { + path: vamc.office?.url || null, + }, + })) + : [], type: banner.type.target_id, } default: