You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
Include requests do work, but there was a design decision early on with caching that resulted in some quirky behavior with the include requests, see #34. There's also another related bug about inconsistent type used by the client for include requests: #35
You can make an include request by adding it to the options object. If it's a single include request, put it in an array as noted in #35: apiClient.type('resource').get('1234', { include: ['otherResource'] })
Or multiple includes: apiClient.type('resource').get('1234', { include: 'otherResource,anotherResource' })
Assuming there aren't any issue with the API you're requesting from, it should return a 200 response in your network tab in dev tools. The client, however, will only return the original requested resource in promise. The includes are put into the cache. You have to form another 'fake' request to get them out of the cache:
apiClient.type('otherResource').get() and this will return in the promise that included resource out of the client cache and won't form another network request.
It's a quirky design decision and not really helpful in real world application, imo. Just so you know, we're not really maintaining this client outside of critical bug fixes at the moment. We're likely moving toward using something like superagent directly rather than an abstraction like this client in the future.
It seems it does not allow to fetch included relationships. As described here: http://jsonapi.org/format/#fetching-includes. Would you consider supporting it?
The text was updated successfully, but these errors were encountered: