I am trying to filter all objects in the projects array that are not in the savedProjects array but the result is an empty array. Am I filtering the wrong way?
My code:
router.post('/get-related', async (req, res) => {
console.log(req.body);
try {
const projects = await Projects.find({researchers: req.body.fullname});
let savedProjects = await Projects.find({projectID: req.body.projectsIDs});
projects.filter(p => savedProjects.includes(p) === false);
res.json(projects);
} catch (err) {
console.log(err);
res.json({ message: err }) };
});
Aucun commentaire:
Enregistrer un commentaire