Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
fileTree anidado de la API de github con okotkit

En mi ejemplo a continuación, trato de obtener un árbol de archivos anidado de mi repositorio de github.
Pero no se anidará.
¿Alguien puede explicarme por qué el ul anidado está solo y el contenido de li no está allí?

 <?php header('Access-Control-Allow-Origin: *'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=1, initial-scale=1.0"> <title>GetGit</title> </head> <style> ul { margin: 0; padding-left: 1em; } li { list-style: none; font-size: .9em; } </style> <body> </body> <script type="module"> const repo = 'KoljaL/picoDocs2'; const authKey = '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'; import { Octokit } from "https://cdn.pika.dev/@octokit/core"; let octokit = new Octokit({ auth: authKey }); let htmlString = ""; octokit.request(`GET /repos/${repo}/git/refs`, { owner: "octokit", repo: "core.js" }) .then(data => { return data.data[0].object.sha; }) .then(sha => { getTree(sha) }) function getTree(sha) { octokit.request(`GET /repos/${repo}/git/trees/${sha}`) .then( data => { return data.data.tree; }) .then( data => { for (let file of data) { console.log(file) if (file.type === "blob") { htmlString += `<li><a href="${file.url}">${file.path}</a></li>`; } else if (file.type === "tree") { htmlString += `<li>${file.path}`; htmlString += '<ul>'; getTree(file.sha) htmlString += '</ul></li>'; } } document.getElementsByTagName('body')[0].innerHTML = htmlString; } ) } </script> </html>

Segundo problema: ¿Por qué no hay contenido si hace clic en un enlace de archivo?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda