Nodejs-Can't set headers after they are sent

Router.get('/info',function(req,res){
    console.log(req)
    const { userid } = req.cookies;
    console.log(userid)
    if( !userid ){
        return res.json({ code : 1})
    }
    User.findOne({_id:userid}, _filter, function(err, doc){
        if(err){
            return res.json({code:1, msg:'后端出错'})
        }
        if(doc){
            return res.json({code:0, data:doc})
        }
    })
    //return res.json({code:1})
})

  

posted @ 2018-01-08 22:35  李大白程序员  阅读(158)  评论(0编辑  收藏  举报