Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.md
6552 views
------{{AddonSidebar()}}
bookmarks.getTree() returns an array containing the root of the bookmarks tree as a {{WebExtAPIRef("bookmarks.BookmarkTreeNode")}} object.
You can access the entire tree recursively using its children property and the children property of its descendants, if they are themselves folders.
This is an asynchronous function that returns a Promise.
Syntax
Parameters
None.
Return value
A Promise that will be fulfilled with an array containing one object, a bookmarks.BookmarkTreeNode object representing the root node.
Examples
This example prints out the entire bookmarks tree:
{{WebExtExamples}}
Browser compatibility
{{Compat}}
Note: This API is based on Chromium's
chrome.bookmarksAPI. This documentation is derived frombookmarks.jsonin the Chromium code.