Skip to content

Commit

Permalink
Fix: check if there is sponsor data before accessing properties from it
Browse files Browse the repository at this point in the history
  • Loading branch information
georgipavlov-7DIGIT committed Apr 11, 2024
1 parent ec129c4 commit 59c03ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions service/controllers/consultation.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ export const getAllConsultations = async ({ country, language, client_id }) => {
const sponsorData = sponsorsData.find(
(sponsor) => sponsor.campaign_id === consultation.campaign_id
);
res.sponsor_name = sponsorData.sponsor_name;
res.sponsor_image = sponsorData.sponsor_image;
if (sponsorData) {
res.sponsor_name = sponsorData.sponsor_name;
res.sponsor_image = sponsorData.sponsor_image;
}
}

response.push(res);
Expand Down

0 comments on commit 59c03ff

Please sign in to comment.