You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I return the response body from callback function? I'm unable to do anything and practically locked inside the callback only!
constcrawler=require('crawler');module.exports={crawler:function(url){letresult=null;letc=newcrawler({maxConnections: 1,callback: function(error,response,done){if(error){returnconsole.error(error)}result=JSON.parse(response.body)//returning result from crawler() ??done()}});c.queue(url)returnresult},}
The text was updated successfully, but these errors were encountered:
During using module architecture you free to organize your code as various of ways, it's not node-crawler package question, but anyway in you case e.g. just pass callback function (or Promise better):
How can I return the response body from callback function? I'm unable to do anything and practically locked inside the callback only!
The text was updated successfully, but these errors were encountered: