Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get included objects in a contentful getEntry call using javascript sdk?

Tags:

contentful

I see that I can pass a query object with include:2 in the getEntries method using the node.js javascript api. How can I do that with the getEntry call that returns a single object.

// how do I get the nested objects by passing the parameter include:1
client.getEntry('<entry_id>', {<what goes here?>})
.then(function (entry) {
  // logs the entry metadata

})
like image 569
MonkeyBonkey Avatar asked Oct 21 '25 16:10

MonkeyBonkey


1 Answers

getEntry returns 1 and only 1 entry. If you want to include the linked entries of 1 parent entry (aka more than one entry), you have to use the getEntries method and specify the sys.id of the parent entry you want to retrieve. Like so:

client.getEntries({'sys.id': '<entry_id>'})
.then(entries => {
  ...
})
like image 96
CharlieC Avatar answered Oct 25 '25 02:10

CharlieC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!