depth
query parameter is higher than 0 (the default value is 1) so that the authors will be returned. Note that any other filtering or order you do to the article will not affect what items are returned within the Linked items element.
The following examples show how to retrieve a single article (named The Origin of Coffee) with its author (a linked item).
In the default JSON response, the codename for your author (jane
in our example) appears in the value
of your author
element. If you have multiple authors, they would appear in the same order in the author
element as they do in the UI.
Jane's name and bio appear in the modular_content
collection under her codename. To use Jane within your article, you need to match the codename from the author
element with the values you want to use from the jane
collection.
{
"item": {
"system": {
"id": "4735c956-4be4-482c-b874-bba201a22f44",
"name": "The Origin of Coffee",
"codename": "the_origin_of_coffee",
"language": "en-US",
"type": "simple_article",
"sitemap_locations": [],
"last_modified": "2020-02-03T12:36:02.7767984Z"
},
"elements": {
"title": {
"type": "text",
"name": "Title",
"value": "The Origin of Coffee"
},
"author": {
"type": "modular_content",
"name": "Author",
"value": [
"jane_doe"
]
}
}
},
"modular_content": {
"jane_doe": {
"system": {
"id": "3bf1c09b-4552-4e2c-8de5-ffce79f773e0",
"name": "Jane Doe",
"codename": "jane_doe",
"language": "en-US",
"type": "author",
"sitemap_locations": [],
"last_modified": "2020-02-03T12:30:14.641708Z"
},
"elements": {
# Omitted for brevity
}
}
}
}
}
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
const KontentDelivery = require('@kontent-ai/delivery-sdk');
const deliveryClient = KontentDelivery.createDeliveryClient({
environmentId: '8d20758c-d74c-4f59-ae04-ee928c0816b7',
});
const response = await deliveryClient.item('the_origin_of_coffee')
.depthParameter(1)
.toPromise();
depth
query parameter to 2 or more.