Returning data from callback

Author: Anan5aCreated Dec 16, 2020Updated Aug 24, 2022

How can I return the response body from callback function? I'm unable to do anything and practically locked inside the callback only!

javascript
const crawler = require('crawler');

module.exports = {
    crawler:function (url){
        let result = null;
        let c = new crawler({
            maxConnections: 1,
            callback: function (error, response, done) {
                if (error) {
                    return console.error(error)
                }
                result = JSON.parse(response.body)
                //returning result from crawler() ??
                done()
            }
        });
        c.queue(url)
        return result
    },

}

Source: bda-research/node-crawler