nodemw icon indicating copy to clipboard operation
nodemw copied to clipboard

support promises

Open MathieuDerelle opened this issue 8 years ago • 3 comments

every function could return a Promise if no callback are passed :

const promise = bot.getCategories('foo')

MathieuDerelle avatar Jul 14 '17 13:07 MathieuDerelle

@MathieuDerelle you can use bluebird's promisifyAll, I am using it and works like a charm, for example:

var clientEs = new bot({
  protocol: 'https',           // Wikipedia now enforces HTTPS
  server: lang + '.wikipedia.org',  // host name of MediaWiki-powered site
  path: '/w',                  // path to api.php script
  debug: false                 // is more verbose when set to true

});



Promise.promisifyAll( clientEs );

clientEs.getPagesInCategoryAsync(category)
.then(function(data) {

	console.log(JSON.stringify(data.map(function(el) {
		return el.title;
	})));

});

ayoze avatar Aug 24 '17 22:08 ayoze

I'm on it

KilianKilmister avatar Jun 25 '20 13:06 KilianKilmister

@KilianKilmister, welcome on board :) Looking forward to your commits.

macbre avatar Jun 25 '20 14:06 macbre