Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/bookmarks/get/index.md
6567 views
---
title: bookmarks.get() slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/get page-type: webextension-api-function tags: - API - Add-ons - Bookmarks - Extensions - Method - Non-standard - Reference - WebExtensions - get browser-compat: webextensions.api.bookmarks.get
---

{{AddonSidebar()}}

Given the ID of a {{WebExtAPIRef("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

    • : string A {{jsxref("string")}} or {{jsxref("array")}} of strings specifying the IDs of one or more {{WebExtAPIRef("bookmarks.BookmarkTreeNode", "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);

{{WebExtExamples}}

Browser compatibility

{{Compat}}

Note: This API is based on Chromium's chrome.bookmarks API. This documentation is derived from bookmarks.json in the Chromium code.