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

Async functions in alterItems don't work #367

Closed
sean-nicholas opened this issue Mar 7, 2018 · 5 comments · Fixed by #371
Closed

Async functions in alterItems don't work #367

sean-nicholas opened this issue Mar 7, 2018 · 5 comments · Fixed by #371

Comments

@sean-nicholas
Copy link
Contributor

Steps to reproduce

I ran the examples from https://feathers-plus.github.io/v1/feathers-hooks-common/#alteritems

You can find my code and output here:
https://gist.github.com/sean-nicholas/c0d73e386743a2b20f690aa473d88134

Expected behavior

alterItems should work with async functions as described in the documentation and in #307

Actual behavior

Promises are not resolved as you can see in the gist output file.

System configuration

Module versions (especially the part that's not working): 4.8.0

NodeJS version: 8.1.4

Operating System: macOS

@sean-nicholas
Copy link
Contributor Author

sean-nicholas commented Mar 7, 2018

I think the example below from the documentation is rather difficult to implement because every property of the (returned) object has to be checked (deep?) if it is a promise.

alterItems(rec => {  rec.userRecord = (async () => await service.get(...) )()})

It might be more straight forward if the users must wrap their whole altering function in a promise / make it a async function.

What do you think?

EDIT: I would be happy to make a PR for this issue

@eddyystop
Copy link
Collaborator

@beeplin ^^^ any comments?

@beeplin
Copy link
Contributor

beeplin commented Mar 8, 2018

I agree with @sean-nicholas.

@sean-nicholas
Copy link
Contributor Author

Okay, I will create a PR in the next few days

@eddyystop
Copy link
Collaborator

Could you also please submit a PR for the docs? The file is feathers-plus/docs/source/feathers-hooks-common/index.md#alteritems . Thanks.

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

Successfully merging a pull request may close this issue.

3 participants