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

90
Views
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
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!