How can I use JavaScript to load a JSON file from my desktop? Alternatively, for a more direct approach:

16 Replies, 736 Views

Wait, are you trying to do this in a browser or Node.js?

For browser: You can't directly javascript load json file from desktop without user interaction (like file input). Security thing.

For Node.js:

```js
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('/path/to/your/file.json'));
```

If you're stuck, share the exact error—might be a path issue!

Messages In This Thread



Users browsing this thread: 1 Guest(s)