My friend and I are collaborating on a game project, but we're encountering an issue when trying to send a Map with some data in it. Instead of receiving the actual Map, Express is sending the user {}
. Strangely enough, when I use console.log
to check the Map, it does display correctly.
Here's the code snippet:
router.get("/list", async (req, res) => {
try {
const users = await userCollection.find();
accessedListEmbed(req);
let userData = new Map();
users.forEach((user) => userData.set(user.userName, user.status));
res.send(userData);
console.log(userData);
} catch (error) {
res.send("unknown");
}
});
https://i.sstatic.net/7v4Fe.png https://i.sstatic.net/UmVLl.png