How to read a file from path


#1

Hello!

I’m trying read a file from a path using the File class but is not working:

this.file = new File([this.path], false)
console.log(this.file);
console.log(this.file.read());

\\return File Object
\\return Uncaught TypeError: this.file.read is not a function

I tried with other functions like isFile(), write(), exists(), but all return same error. When instantiating a File object in dev console, on autocomplete, appear only this functions options:

What the right way to read a file content from some path?


#2

If the File API isn’t working for you, you could try Node’s fs module.