Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would you be open to supporting promises? #53

Open
bookercodes opened this issue Apr 1, 2016 · 12 comments
Open

Would you be open to supporting promises? #53

bookercodes opened this issue Apr 1, 2016 · 12 comments

Comments

@bookercodes
Copy link

Hi. Nice work on this module -- I'm using it for my site, Community Casts.

I was wondering, would you be open to accepting a pull request that adds support for Promises?

@IonicaBizau
Copy link
Owner

@alexbooker Definitely. But I guess the right place to implement it is directly in googleapis and then bump the dependency version here. /cc googleapis/google-api-nodejs-client#523

Also, you can promisify these callback-based functions anytime. 🔮

@IonicaBizau
Copy link
Owner

@alexbooker I upgraded the googleapis dependency in #56. Promise support was added in googleapis/google-api-nodejs-client@74fd970 so it just landed in this library too. 🎉

@bookercodes
Copy link
Author

@IonicaBizau Awesome 👍

@bookercodes
Copy link
Author

Would you mind adding an example to the documentation?

I tried:

const videoList = await youtubeApi.videos.list({
  id: videoId,
  part: 'snippet,contentDetails'
})

... But I'm not getting the result I was expecting. I'm getting a Request in return when I would expect a response.

@IonicaBizau
Copy link
Owner

@alexbooker I didn't test the code, but by reading the code, I think you have to do something like this:

const videoList = await youtubeApi.videos.list({
  id: videoId,
  part: 'snippet,contentDetails'
}).promise;
// ^ notice the promise field

@bookercodes
Copy link
Author

@IonicaBizau Thanks, but I don't think that's it.

Notice the lack of await. I am inspecting the promise property and it's undefined:

@bookercodes
Copy link
Author

As far as I can tell, the pull request you linked hasn't been merged 😕

@IonicaBizau
Copy link
Owner

@alexbooker Oh, that's correct... 😭

@bookercodes
Copy link
Author

@IonicaBizau Maybe reopen this issue?

@IonicaBizau IonicaBizau reopened this May 30, 2016
@IonicaBizau
Copy link
Owner

👍

@IonicaBizau IonicaBizau removed their assignment Jun 8, 2016
@ulion
Copy link

ulion commented Aug 12, 2016

@IonicaBizau when will the new version of the googleapis library be released? it's been 8 months since v2.1.7 and the promise feature should be released to public version asap?

@IonicaBizau
Copy link
Owner

@ulion Honestly, I don't have any idea, but maybe we can add the promise support in this library. We must make sure the last argument is the callback function always (in all the methods). Contributions are welcome in that direction!

For callback-compatibility, I would recommend using assured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants