Get node children
Log in to add to favouritesCall the nodes.getChildren() method in our delivery client to get the child nodes of an existing node from site view, optionally resolving an attached entry
Call signatures
getChildren(id: string): Promise<Node[]>
getChildren(node: Node): Promise<Node[]>
getChildren(options: NodeGetChildrenOptions): Promise<Node[]>
Parameters
Name | Type | Description |
---|---|---|
id | string | The id of the node |
node | Node | A node object |
options | NodeGetChildrenOptions | An options object to apply additional refinements |
Returns
A Promise that will resolve an array of Node
Remarks
Returns an empty array if no nodes exist with the specified entry
Throws any error that is returned by the API for any other unsuccessful request echoing the HTTP status returned from the API
Example
Get the child nodes of an existing node
const children = await client.nodes.getChildren(
"7a301bf2-96c3-461c-8068-bebe6783ecc5"
);
for (const node of children) {
console.log(node.path);
}
Get the child nodes of an existing node also resolving the entryTitle field of any entry attached to the returned nodes
const children = await client.nodes.getChildren({
id: "7a301bf2-96c3-461c-8068-bebe6783ecc5",
entryFields: ["entryTitle"],
});
for (const node of children) {
console.log(`${node.path} ${node.entry?.entryTitle}`);
}