Hello.I wanted to access data.json file on my computer with js. Then I learned that json file must be on a server to access js. To run the server, I switched the data.json file to the directory where it is located and ran the server with the following command: python3 -m http.server. When I type http://127.0.0.1:8000/data.json in the address cubug, the server is working properly and it appears in json data. But when I try to access this file with js like this:
var request = new XMLHttpRequest()
request.open("GET","http://127.0.0.1:8000/data.json",true)
request.onload = function () {
var data = JSON.parse(this.response)
console.log(data);
}
For some reason I can not get any output. Where is the problem? I am running my server incorrectly, I am accessing incorrectly with js or am I following a wrong path in general? I will be glad if you can help.