Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Console log statement not showing up at all in console with Chrome Extension API

I am attempting to cycle through one of my bookmarks folders and log the title and url of the bookmarks from the array. Whenever I am trying to log the array for testing, an object doesn't appear at all, nothing is null or undefined. The first 2 logs show the arrays with their designated nodeTree location. What am I missing in the function to return the title and url of each bookmark to the console?

    chrome.bookmarks.getTree(function(bmTree){
        bmTree.forEach(function(node){
            console.log(node);
            // * Variables are hardcoded for development
            // * reaches Resources folder in Coding Folder
            // TODO: declare variable = to userInput from bookmark tree
            let list = node.children[0].children[2].children[1];
            console.log(list);
            // Retrieve bookmarks title and url
            for (let i = 0; i < list.length; i++){
                const bkmk = [
                    list.children[i].title,
                    list.children[i].url
                ];
                console.log(bkmk);             
            };
        });
    })
};

enter image description here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The answer was a simple tweak, instead of using list.length, I needed to use list.children.length. Code samples below:

Original:

    chrome.bookmarks.getTree(function(bmTree){
    bmTree.forEach(function(node){
        console.log(node);
        // * Variables are hardcoded for development
        // * reaches Resources folder in Coding Folder
        // TODO: declare variable = to userInput from bookmark tree
        let list = node.children[0].children[2].children[1];
        console.log(list);
        // Retrieve bookmarks title and url
        for (let i = 0; i < list.length; i++){
            const bkmk = [
                list.children[i].title,
                list.children[i].url
            ];
            console.log(bkmk);             
        };
    });
})

Fixed:

const getBookmarks = () =>{
chrome.bookmarks.getTree(function(bmTree){
    bmTree.forEach(function(node){
        console.log(node);
        // * Variables are hardcoded for development
        // * reaches Resources folder in Coding Folder
        // TODO: declare variable = to userInput from bookmark tree
        let list = node.children[0].children[2].children[1];
        console.log(list);
        // Retrieve bookmarks title and url
        for (let i = 0; i < list.children.length; i++){
            var bkmk = [list.children[i].title, list.children[i].url];

            console.log(bkmk);           
        }; 
    });
})
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!