MDN self-hosted library · e01.org

bookmarks.get()

Given the ID of a bookmarks.BookmarkTreeNode or an array of such IDs, the bookmarks.get() method retrieves the matching nodes.

Open notebook · 1 cells webextension-api-function upstream source

Given the ID of a bookmarks.BookmarkTreeNode or an array of such IDs, the bookmarks.get() method retrieves the matching nodes.

This is an asynchronous function that returns a Promise.

Syntax

let getBookmarks = browser.bookmarks.get(
  idOrIdList                // string or string array
)

Parameters

  • idOrIdList
  • : A String or Array of strings specifying the IDs of one or more BookmarkTreeNode objects to retrieve.

Return value

A Promise that will be fulfilled with an array of BookmarkTreeNode, one for each matching node. Separators are not included in the results. If no nodes could be found, the promise will be rejected with an error message.

Examples

This example tries to get the bookmark whose ID is bookmarkAAAA. If no bookmark with this ID exists, onRejected is called:

function onFulfilled(bookmarks) {
  console.log(bookmarks);
}

function onRejected(error) {
  console.log(`An error: ${error}`);
}

let gettingBookmarks = browser.bookmarks.get("bookmarkAAAA");
gettingBookmarks.then(onFulfilled, onRejected);

Browser compatibility

[!NOTE] This API is based on Chromium's chrome.bookmarks API. This documentation is derived from bookmarks.json in the Chromium code.