Q:

I do I parse the string from req.query?

I am supposed to retrieve the string from my req.query in express. I am implementing a RESTFul API and my code looks like
router.get('/', function(req, res) {

    var count = req.query.count;
    var sorting = req.query.sort;
    //let obj = JSON.parse(sorting)

    if(count == "true") {
        user.find({}, function(err, users) {
            if(err){
                res.status(404).send({
                    message: err,
                    data: []
                });
            } else {
                res.status(200).send({
                    message: 'OK ttt',
                    data: users.length
                });
            }
    });
    } 

Let's say my 
var sorting = req.query.sort

Give me {\"name\": 1}"
I want to parse out the "name" from this.
I used 
JSON.parse(sorting)

But it returned an object, not a string.

A:

JSON.parse indeed returns an object: The object parsed from the JSON string you pass to the function. In this case it will return the object {name: 1}.
To get the value for the name property you can do:
var name = JSON.parse(sorting).name;

