diff --git a/src/components/ListingCard/ListingCard.js b/src/components/ListingCard/ListingCard.js index a1e1d788..bd5b5448 100644 --- a/src/components/ListingCard/ListingCard.js +++ b/src/components/ListingCard/ListingCard.js @@ -6,9 +6,11 @@ import css from './ListingCard.css'; const ListingCard = props => { const { listing } = props; const id = listing.id.uuid; - const { title, description, address } = listing.attributes; + const { title = '', description = '', address = '' } = listing.attributes || {}; const slug = encodeURIComponent(title.split(' ').join('-')); - const authorName = `${listing.author.attributes.profile.firstName} ${listing.author.attributes.profile.lastName}`; + const authorName = listing.author && listing.author.attributes + ? `${listing.author.attributes.profile.firstName} ${listing.author.attributes.profile.lastName}` + : ''; // TODO: these are not yet present in the API data, figure out what // to do with them diff --git a/src/components/ListingCardSmall/ListingCardSmall.js b/src/components/ListingCardSmall/ListingCardSmall.js index 94a74d80..4c08e8ae 100644 --- a/src/components/ListingCardSmall/ListingCardSmall.js +++ b/src/components/ListingCardSmall/ListingCardSmall.js @@ -5,7 +5,7 @@ import css from './ListingCardSmall.css'; const ListingCardSmall = props => { const { listing } = props; - const title = listing.attributes.title; + const { title = '' } = listing.attributes || {}; const id = listing.id.uuid; const slug = encodeURIComponent(title.split(' ').join('-'));