-
Notifications
You must be signed in to change notification settings - Fork 90
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
Way to consume relationships on the fly ? #215
Comments
Check out the README section on the URL Builder. This may work: const comments = await post.all('comment').get(); |
I believe the deserialization step in Devour throws away the information that's needed for what you like to do @alberto-f . I could be mistaken though.. I would like to have this functionality too; and I already thought about it. There's one problem that's keeping me from implementing it though: (using the code from your example) I see two solutions (with several downsides):
const post = await jsonApi.find('post', '1');
post.attributes.title // => the attribute "title"
post.title // a delegate to the title attribute
post.relationships.comments // => a relationship-object with methods like get and delete
post.relationships.comments.included[0] // => a resource-object; an [included related resource](https://jsonapi.org/format/#fetching-includes)
post.comments // a delegate to an included resource (only available if it's included) I doubt that my second solution will be popular with the users of this library though since it seems like this was a deliberate design decision that was made long ago. |
Hello, thanks for the project. It is really nice structure and the middlewares are a really nice feature.
I was wondering if there is any way to continue consuming the responses
Example:
The text was updated successfully, but these errors were encountered: