Open
Description
How can I return the response body from callback function? I'm unable to do anything and practically locked inside the callback only!
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
},
}
Metadata
Metadata
Assignees
Labels
No labels