DEV Community

Mohamed Abdelgaber
Mohamed Abdelgaber

Posted on

I send req body array => req.body[“subjects”] <= i want find => subject: element of array <=

{ const exams = require("../models/exams.model");

    exports.exam = (req, res, next) => {
        var Array = JSON.parse(req.body["subjects"])
        exams.find({
        subject: Array element,
        })
 .then(
        examData => {
            if (examData != null)
                res.status(200).json(examData)
            else {
                res.status(500).json({
                    success: false,
                    msg: "error incorrect "
                })
            }
            console.log(examData)
        }
    ).catch(

/* error => { res.status(500).json({ success…

Top comments (0)