jculvey / roboto

A web crawler/scraper/spider for nodejs
66 stars 24 forks source link

Pass error on finish event on exit due to error #20

Open bogusfocused opened 7 years ago

bogusfocused commented 7 years ago

To create a promise out of crawl method we require a finish event with error.


asyncCrawl() {
        return new Promise((resolve, reject) => {
            this.crawler.on('finish', function (err) { if(!err) resolve(); else reject(err) });
            this.crawler.crawl();
        })
    }