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

92
Vistas
How do I list all elements from a JSON array in VSCode's Webview?

I'm trying to read, parse and display the elements of a JSON for my extension, but somehow it's not getting displayed.
My code before the HTML part in _getHtmlForWebview(), where I declare the array is this:

const fs = require('fs');
const configsList = fs.readFileSync('./configuration.json', 'utf8');

Everything works here, I tried console.log(configList) and the array is printed as it should. So no problems here.
Next I tried to iterate over the data array in the HTML like this (just parts):

In the <HTML> part:

function displayConfigs() {
    var mainContainer = document.getElementById("target-id");
    data = ${configList}
    for (var i = 0; i < data.length; i++) {
        var div = document.createElement("div");
        div.innerHTML = 'Config ID: ' + data[i].id + ', Config Name: ' + data[i].name;
        mainContainer.appendChild(div);
    }
}

And executing it in the <Script> part:

<span onclick="displayConfigs()"><button> <strong>Display Configs</strong> </button></span>
<div id="target-id"></div>

But after pressing the button in my webview, nothing happens

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