Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To make an APIcall to access a file on disc we need to use a webserver. To spin up a webserver, navigate to the folder you would like to be able to access and run:

Code Block
python3 -m http.server --cgi 8080

The only thing that you will need to do is change the APIcall to use a “GET” method since this webserver has some limitations.

In this example you can try using the on loaded event to fire off an APIcall. The file “example.json” is a file that is located in the folder that the webserver is running.

Code Block
READYevent(function(){
   var Path = "example.json";
   APIcall(Path,{},APIsuccess);
});

function APIsuccess(Data){ console.log("Successful API call", Data); }

For more reading about starting a simple webserver