Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda