youtube-node icon indicating copy to clipboard operation
youtube-node copied to clipboard

Convert it to promise base

Open malik-umair opened this issue 8 years ago • 1 comments

Hi, I'm using this wonderful API and it worked perfectly. But I need it to be promise base as my whole application is promise base and this API return result few second late and script doesn't stop for it and bypass it. Is there a way I use it as promise base? Thanks!

malik-umair avatar Sep 29 '16 06:09 malik-umair

You can use the library with the ES6 Promise class or some of the promise similar libraries for pre ES6 environments; e.g.:

var promise = new Promise(function(resolve, reject) {
    Youtube.search('bla bla', 2, function(err, result) {
        resolve(result)
    }
})

christopher-ramirez avatar Sep 30 '16 03:09 christopher-ramirez