javascript read file as string 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: javascript store text file into string
var fs = require("fs");
fs.readFile("./mytext.txt", function(text){
var textByLine = text.split("\n")
});