Answer the question
In order to leave comments, you need to log in
How to implement reading bookmarks after loading settings from storege?
Greetings!
I am writing an extension that displays bookmarks in chrome like opera.
Implemented specifying the ID of the root folder of bookmarks from which to read. I save the settings in chrome.storage.sync. And then I read them from there.
Faced a problem.
Since reading settings from storage is asynchronous, I need to start displaying bookmarks after reading the settings is completed. But as soon as I put the bookmark output code in the callback function of the read settings function, I get an error.
const getSettingsFromStorage= () => {
chrome.storage.sync.get(["SETTINGS"], (result) => {
const keys = Object.keys(result.SETTINGS)
for (key of keys) {
if (key != 'SETTINGS') {
SETTINGS[key] = result.SETTINGS[key]
}
}
loadedSettings = true
getBookmarks()//эта функция выводит закладки
})
}
Error handling response: TypeError: Error in invocation of bookmarks.getSubTree(string id, function callback): No matching signature.
at getBookmarks (chrome-extension://einifcmggplbnlegodnhbibgbhcdjdeg/script.js:148:26)
at chrome.storage.sync.get (chrome-extension://einifcmggplbnlegodnhbibgbhcdjdeg/settings.js:27:9)
getSettingsFromStorage()
getBookmarks()//вывод закладок на страницу
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question