Sending data from APi

exports.getComments = async function(req, res, next) {
	try {
		console.log('request came for fetching comment');

		let foundPlaylist = await Playlist.findById(req.params.playlist_id).populate('comment');
		let foundComments = await foundPlaylist.comments.map(async (comment) => {
			let com = await Comment.findById(comment._id);
			return com;
		});
	
		console.log('before sending data', foundComments);
		return res.status(200).json(foundComments);
	} catch (error) {
		return next(error);
	}
};

this is the function i use when i call fetching comments for particular playlist . here i use async await but before sending data to front end i got array of empty objects of comments. can you help me with this?

check if the req object contains that param.
try to get that param and store it in a variable
and pass that variable to DB functions

for second instead of populated variable get the data from foundPlaylist

Try the following instead:

		let foundComments = await  Promise.all(
          foundPlaylist.comments.map(async (comment) => {
			let com = await Comment.findById(comment._id);
			return com;
		  })
        );