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

Please bind the function #79

Closed
jcalfee opened this issue May 10, 2020 · 3 comments
Closed

Please bind the function #79

jcalfee opened this issue May 10, 2020 · 3 comments

Comments

@jcalfee
Copy link

jcalfee commented May 10, 2020

Could you please add a bind to the wrapped function so this will work?

@jcalfee
Copy link
Author

jcalfee commented May 10, 2020

On second thought, I guess you can't do that. You don't have access to the parent object.

I went down this rabbit hole, because the API I'm using has nested objects off of their main API and pify does not seem to have a method to step into and promisify those functions. So, attempting to bind a nested function broke the API because this was undefined. So I guess I need to iterate those objects and apply pify to each one.

@jcalfee jcalfee closed this as completed May 10, 2020
@jcalfee
Copy link
Author

jcalfee commented May 10, 2020

If I try to promisify each function, this is what I have to do:

await pify(sdk.billingPlan.list.bind(sdk.billingPlan))()

Seems like there should be a better way:

pify(sdk.billingPlan, 'list')()

@sindresorhus
Copy link
Owner

@jcalfee See: #78 I don't think we want to add such an API. You can just do pify(sdk.billingPlan).list().

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

No branches or pull requests

2 participants