Get the root node
Log in to add to favouritesCall the nodes.getRoot() method in our delivery client to return the root node from the project site view tree
Call signatures
getRoot(options?: NodeGetRootOptions): Promise<Node>
Parameters
Name | Type | Description |
---|---|---|
options | NodeGetRootOptions | An options object to apply additional refinements |
Returns
A Promise that will resolve with the root Node
Remarks
Throws any error that is returned by the API for any unsuccessful request echoing the HTTP status returned from the API
Example
const node = await client.nodes.getRoot();
console.log(node);
const node = await client.nodes.getRoot({
depth: 1,
language: "en-GB",
entryFields: ["entryTitle"],
});
for (const child of node.children) {
console.log(
child.path,
child.childCount ? `+${child.childCount}` : "",
child.entry?.entryTitle || ""
);
}