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

Mutating data from an API call #23

Closed
ZeroThe2nd opened this issue Mar 1, 2019 · 2 comments
Closed

Mutating data from an API call #23

ZeroThe2nd opened this issue Mar 1, 2019 · 2 comments

Comments

@ZeroThe2nd
Copy link

In the current version, there does not seem to be (or its undocumented) a way to mutate an API response before it's being saved/loaded etcetera.

Using an external API, which in my case provides far more information than is needed for the application to function, I only need a few values from an API response. However some are nested in sub-objects. While for the application I'm only in need of (for example) member.username, memberships.active.id and displayName, there currently is no way to "cherry pick" the desired data in a mutator function on a model or specific call.

Partially related to #21

@aveeday aveeday mentioned this issue Mar 26, 2019
@kiaking
Copy link
Member

kiaking commented Oct 21, 2019

The brand new Axios plugin is here! It's very different from what it was, so please check out the docs!

You can cherry pick the field by creating only those field at Model schema definition 👍

@kiaking kiaking closed this as completed Oct 21, 2019
@ZeroThe2nd
Copy link
Author

While the new plugin version certainly cleans up some things, also making it less conflicting with other ORM plugins, it still does not provide a (documented) way to mutate a response before this is stored.

As for the updated way of handling the URL in the new Model.api().[get|post|put|patch|delete]() function, I think it's extra redundant code that is error sensitive if this is done for every place a model is used with the API. I'll make another issue after digging though the code, and provide a proposal if I come up with something nice. Same goes for the delete thing mentioned in the documentation.

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