How can I use JavaScript to load a JSON file from my desktop? or What's the best way to load a JSON f

14 Replies, 1329 Views

FileReader API is cool but yeah, it needs user interaction. No way around that for security reasons.

If you’re building something quick and dirty, you could just paste the JSON directly into your JS file as a variable. Not scalable, but gets the job done.

Otherwise, local server is the way. Here’s how to do it with Node:
```bash
npx http-server
```
Then access your file at `http://localhost:8080/data.json`. Easy peasy.

Messages In This Thread



Users browsing this thread: 1 Guest(s)