Skip to content

Instantly share code, notes, and snippets.

@michaelnagy
Created September 7, 2016 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelnagy/d649f0d54b87453d10a18da02f0943f7 to your computer and use it in GitHub Desktop.
Save michaelnagy/d649f0d54b87453d10a18da02f0943f7 to your computer and use it in GitHub Desktop.
client.getEntries()
.then(function (entries) {
// getting all the entries in a global var
content = entries;
entries.items.forEach(function (entry, index) {
if (entry.sys.contentType.sys.id == 'event') {
//separating the events type entries in a global var
events[index] = entry;
console.log(entry.fields.image.fields.file.url); // this shows me undefined on console.log
// if you inspect the entry object you will see a getter not resolved in image property, like in the screenshot: http://prnt.sc/cf9vmq
// After clicking the getter runs and the image gets filled, my question is, why this is not getting filled along with all the object?
// http://prntscr.com/cf9wtn
}
});
});
// Comment for the contentfull support team
// When I console.log the linked properties for the events array, I get undefined property
@Khaledgarbaya
Copy link

Hi there,
based on your data there is not field called image that's why you are getting undefined. However there is an array of images, called images and to access the url you can do

console.log(entry.fields.images[0].fields.file.url);

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