Search code examples
firefoxsdkfirefox-addon-sdkbookmarks

Firefox add-on SDK / places/bookmarks API: How to get *all* bookmarks?


I am trying to access bookmarks using the places/bookmarks API from the Add-on SDK for Firefox. I am able to query the bookmarks, searching for some given keywords etc. but if I just try

search(
  { query: "" }
).on("end", function (results) {
  // results matching any bookmark that has "firefox"
  // in its URL, title or tag, sorted by title
  console.error(results);
}

I do not get any output. Is this expected? How would I do a catch-all query?

(As correctly hinted at in the comment, for small numbers of search results, the above code does return all bookmarks.)


Solution

  • Your code is correct:

    search(
        { query: "" }
        ).on("end", function (bookmarks) {
            // do something
    }
    

    This is exactly the way it should work. I am using the same code and have tested that the search does retrieve all my around 1500 bookmarks.

    My assumption is that you made an error while testing. For example, when running "cfx run" using the Firefox SDK, the test browser does not contain your bookmarks, you would have to create or import bookmarks first.