How to read data from file in JavaScript code example
Example 1: read file javascript
// As with JSON, use the Fetch API & ES6
fetch('something.txt')
.then(response => response.text())
.then(data => {
// Do something with your data
console.log(data);
});
Example 2: how to load localt ext file in js
const fileUrl = '' // provide file location
fetch(fileUrl)
.then( r => r.text() )
.then( t => console.log(t) )