Hello I have this function which fills an array for me. When I output the array in the for loop it contains elements. However, when I return below with resolve and then call the function and return with then the array seems to be empty.
How can I return this array correctly?
getUrlsOfFolder(id){
return new Promise(async (resolve) =>{
let urls = new Array();
chrome.bookmarks.getSubTree(id,(searchResult) => {
for(const key of searchResult){
if(key.children){
let children = key.children;
for(const child of children){
if(child.url){
urls.push(child.url);
}
}
}
}
});
resolve(urls)
});
}