why does getJson to retreive server directory list works with liveserver but not with html-live-server

32 views Asked by At

I am writing a full stack app to control measurement equipment. For the moment I am working on the frontend. My IDE is Visual Studio Code 1.87.1,Live Serveerv5.7.9(Ritwick Dey), html-live-server v0.2.0(Naveen Vignesh). I wrote a javascript to retrieve the directory list containing configuration files, users should be able to choose an existing configuration from the server . This works well on Live Server but fails with html-live-server: the getJSON call returns nothing. Everything runs on local host.

// populate file dropdown list
function fileList() {
    console.log("get dir info");
    $.getJSON('profiles', data => {
        var options = "";
        data.map((op, i) => {
            options += `<option value="${op}" id="${i}" style="border-radius: 5px;"">${op}</option>`;
        })
        document.getElementById("dir").innerHTML = options;
        console.log(data);
        dirdata = data;

    });
}

I switched to html-live-server because Live Server has issues with fetch POST methode (see https://github.com/ritwickdey/vscode-live-server/issues/541)

As my code only works on one server it's probably bad code

Adding the console.log instructions to check the path and the result show's that the path is well formed with both servers but nothing seems to be returned with second server. What I can find on internet about getJSON is way over my head and doesn't seem appropriate.

0

There are 0 answers