From 3e151e86eb3cdf566482a02475db1d15cbdec309 Mon Sep 17 00:00:00 2001 From: vovastelmashchuk Date: Sun, 15 Sep 2024 21:06:43 +0300 Subject: [PATCH] add fallback to empty array --- features/cocktail/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/cocktail/utils.js b/features/cocktail/utils.js index 40bfa70..636cb31 100644 --- a/features/cocktail/utils.js +++ b/features/cocktail/utils.js @@ -3,8 +3,8 @@ const Database = require('../../database/newclient'); const { getCocktailBySlug } = require("../../database/cocktail"); async function getRecomendations(cocktail) { - const goodMatchSlugs = cocktail.matches.good; - const otherMatchSlugs = cocktail.matches.other; + const goodMatchSlugs = cocktail.matches.good || []; + const otherMatchSlugs = cocktail.matches.other || []; const goodCocktails = await Database.collection('cocktails') .find({ slug: { $in: Array.from(goodMatchSlugs) } })