Open Tharvinash opened 3 years ago
at exports.getScream:
exports.getScream = (req, res) => { let screamData = {}; db.doc(/screams/${req.params.screamId}) .get() .then((doc) => { if (!doc.exists) { return res.status(404).json({ error: 'Scream not found' }); } screamData = doc.data(); screamData.screamId = doc.id;
/screams/${req.params.screamId}
return db .collection('comments') .orderBy('createdAt', 'desc') .where('screamId', '==', req.params.screamId) .get(); }) .then((data) => { screamData.comments = []; data.forEach((doc) => { screamData.comments.push(doc.data()); }); return res.json(screamData); }) .catch((err) => { console.error(err); res.status(500).json({ error: err.code }); });
};
it says that TypeError: data.forEach is not a function. Is there a solution to solve it. Thank you in advance
at exports.getScream:
exports.getScream = (req, res) => { let screamData = {}; db.doc(
/screams/${req.params.screamId}
) .get() .then((doc) => { if (!doc.exists) { return res.status(404).json({ error: 'Scream not found' }); } screamData = doc.data(); screamData.screamId = doc.id;};
it says that TypeError: data.forEach is not a function. Is there a solution to solve it. Thank you in advance