// get the file
fetch("path/to/file.extension")
// get the text within the file
.then((res) => res.text())
// if you are reading from a json file:
// .then((res) => res.json())
// do something with the text
.then((fileContents) => console.log(fileContents));