0

I am beginer at js. I work with node.js. I want to get a value for my variable outside from callback. Can anyone tell me, is this way correct?

.get('/add', async (req, res) => {
        var a;
        await mongoModel.find({}, (err, model) => {
            a = 5;
        })
        console.log(a);//I want "a" = 5, not undefined
    });

0 Answers0