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

what are 'errors' and 'includes' properties in the getEntries() response object? #69

Closed
chriswu14 opened this issue Mar 30, 2016 · 5 comments

Comments

@chriswu14
Copy link

this is what my client code look like, everything works fine I get my content but when I am learning based on the API documentation I cannot find any info about these two objects.

var client = contentful.createClient({ accessToken: '****', space: '****' }); client.getEntries().then(entries => { console.log(entries) })

the response is
image

@trodrigues
Copy link
Contributor

Hi @chriswu14,

these are properties returned by the Contentful REST API.

The includes property doesn't really need to be there, as it includes entries or assets that might be linked from the ones included in the items array. Those links are resolved automatically, so the includes array doesn't need to be exposed. I'll look into removing it.

As for the errors property, it might include errors which occurred in retrieving some of the entries. I will add this to the documentation.

@chriswu14
Copy link
Author

Thanks for the reply, I figured later on that I started my account with a prefilled sample one and deleted some of the author content may be there was some linking between them.

@HauntedSmores
Copy link

HauntedSmores commented Oct 26, 2017

@trodrigues Hey, I know this is an old issue but theres still some inconsistencies, at least from my understanding, with the includes array. The includes array is also still being sent in the response from the SDK, even though the default resolveLinks: true is set.

Its described here as the place where linked asset/entry data is resolved (i.e. urls). The language is very vague, for instance:

linked items are placed in the includes array, when not already fetched in the items array.

And from here

If the standard items array has not already retrieved the linked entries, they will be in the includes.Entry array. Linked assets are inside the includes.Asset array.

What the hell is "when not already fetched in the items array" or "if the standard items array has not already...."?.

If Im writing an app, I need to know exactly where in the response Im getting my data. Is it gonna be in includes[] or in the actual items array object? It looks like both for me. But my app is currently looking for nested linked stuff in the objects inside the items array. This is what made the most sense to me - each item in items[] has a linked asset/entry so I should be looking in items[x].fields.my_linked_field[x].fields for my linked data.

Basically - How will I know, programmatically, when the linked entities will be in the items array or in the includes array? Is this different for entries vs assets? Testing my space with resolveLinks: false, it seems like never - the regular REST API will always just return a bunch of results with type: link and dump the actual data in includes[]. Im just really confused by the language I believe.

@Khaledgarbaya
Copy link
Contributor

Hi @HauntedSmores,
If the entry is already in the items array it does not make sense to include in the includes array this will lead to duplication of content and a bigger payload.
When resolving the links you need to look into both items and includes.
That's what we do in the SDK already since we resolve the links for you.
You can check the code here.

Best,
Khaled

@HauntedSmores
Copy link

@Khaledgarbaya Thanks a lot for the clarification. I also had the same explanation from contentful support, who are always on the ball. Great work on the SDK and the platform in general. My team let me run with Contentful for my current project and I think I may have successfully killed WordPress around here. Thanks for that!

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

4 participants