Get node siblings
Log in to add to favouritesCall the nodes.getSiblings() method in our delivery client to get the sibling nodes of an existing node from site view, optionally resolving an attached entry
Call signatures
getSiblings(id: string): Promise<Node[]>
getSiblings(node: Node): Promise<Node[]>
getSiblings(options: NodeGetSiblingOptions): Promise<Node[]>
Parameters
Name | Type | Description |
---|---|---|
id | string | The id of the node |
node | Node | A node object |
options | NodeGetSiblingOptions | An options object to apply additional refinements |
Returns
A Promise that will resolve an array of Node
Remarks
Returns an empty array if no sibling nodes are returned
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 sibling nodes of an existing node
const node = await client.nodes.getSiblings(
"7a301bf2-96c3-461c-8068-bebe6783ecc5"
);
for (const node of nodes) {
console.log(node.path);
}
Get the sibling nodes of an existing node also resolving the entryTitle field of any entry attached to the returned nodes
const nodes = await client.nodes.getSiblings({
id: "7a301bf2-96c3-461c-8068-bebe6783ecc5",
entryFields: ["entryTitle"],
});
for (const node of nodes) {
console.log(
node.path,
node.childCount ? `+${node.childCount}` : "",
node.entry?.entryTitle || ""
);
}