Skip to content

Commit

Permalink
Check banner object for field before trying to iterate over it. (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
timcosgrove authored Dec 12, 2024
1 parent 710214f commit 4bf77e6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/data/queries/banners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ export const formatter: QueryFormatter<any, BannersData> = (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:
Expand Down

0 comments on commit 4bf77e6

Please sign in to comment.