From 0430710522cfb064addac40fb81d9fca3c11ae49 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Wed, 15 May 2024 02:33:26 +0200 Subject: [PATCH] Fixed: reviews data now contains info about beer --- frontend/app/(app)/(tabs)/review/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/app/(app)/(tabs)/review/index.js b/frontend/app/(app)/(tabs)/review/index.js index 8fdbd56..f644d68 100644 --- a/frontend/app/(app)/(tabs)/review/index.js +++ b/frontend/app/(app)/(tabs)/review/index.js @@ -23,6 +23,28 @@ export default function Tab() { let data = await res.json(); // show only logged in user's data data = data.data.filter((review) => review.user_id == user._id); + + let beers = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/beer/get`, { + method: "GET", + credentials: "include", + }); + beers = await beers.json(); + beers = beers.data; + console.log(beers); + + async function getBeerParam(search, beers) { + for (let i = 0; i < beers.length; i++) { + if (beers[i]._id == search) { + return beers[i]; + } + } + return null; + } + + data.forEach(async (el) => { + el.beer = await getBeerParam(el.beer_id, beers); + }); + console.log("reviews", data); setData(data); } catch (err) {