solution ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 async function printBookmarks(id, shift) { // chrome.bookmarks.getChildren(id, function(children) { const getBoomarksChildrensPromise = (id) => new Promise (r =>chrome.bookmarks.getChildren(id, r )); const childrens = await getBoomarksChildrensPromise(id); for (const bookmark of childrens) { if (!bookmark.url) { document.getElementById("Output").innerHTML += shift+"<button id=\""+bookmark.id+"\" class=\"folder\" >"+bookmark.title+""; await printBookmarks(bookmark.id, shift+"<br>"); console.log(bookmark.title); } } } old ways ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27function printBookmarks(id, shift) { chrome.bookmarks.getChildren(id, function(children) { for (const bookmark of children) { if (!bookmark.url) { document.getElementById("Output").innerHTML += shift+"<button id=\""+bookmark.id+"\" class=\"folder\" >"+bookmark.title+""; printBookmarks(bookmark.id, shift+"<br>"); console.log(bookmark.title); } } }); } // original function printBookmarks(id, shift) { chrome.bookmarks.getChildren(id, function(children) { children.forEach(function(bookmark) { if (!bookmark.url) { document.getElementById("Output").innerHTML += shift+"<button id=\""+bookmark.id+"\" class=\"folder\" >"+bookmark.title+""; printBookmarks(bookmark.id, shift+"<br>"); console.log(bookmark.title); } }); }); }