I have a dictionary text file in the project folder and I would like to read it and put items in an array in my App.js file. How can I do that?
Here is how the project looks: Here
I have a dictionary text file in the project folder and I would like to read it and put items in an array in my App.js file. How can I do that?
Here is how the project looks: Here
First import the text file.
import dir from './dir.txt';
then you can fetch and transform it into text:
fetch(dir)
.then(row => row.text())
.then(text => {
console.log('text:', text);
});