3

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

})
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460

1 Answers1

6

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 => {
  ...
})
CharlieC
  • 502
  • 3
  • 8
  • 1
    UPDATE: as of [v7.0.0 of the Contentful.js](https://github.com/contentful/contentful.js) library, the `getEntry` function will also do link resolution. [See this for more details](https://github.com/contentful/contentful.js/blob/master/ADVANCED.md#link-resolution) – CharlieC Aug 31 '18 at 17:13