Mongoose Query n[SOLVED]

Mongoose Query n[SOLVED]
0

#1
let extractTags = (req,res) =>{
    Data.find({ tags : 'hav' }, function (err, data) {    
        res.json(data)
    }

------------------------------------------------------------------------------

    var tag = req.query.tag
    Data.find({ tags : tag}, function(err, data){
        res.json(data)
    }
    })

tags schema type is Array. When i pass ‘hav’ explicitly the query return the desired result.
But when i try to pass it through a variable it returns empty object (i have checked the variable value is ‘hav’)


#2

What was the solution to your problem?


#3

I was passing the query wrong

i was doing localhost:5000?extractTags=“hav”

So the tag in this case was “\“hav\””

Just had to did localhost:5000?extractTags=hav