How can I store text file's content to string variable using fetch? I'm using React.js and my File's content is being read in console, but I cannot seem to store it.
Naturally, TextFile returns me undefined, but I wonder if there is a way to catch a promise and store it permanently in a string var? Thank you in advance; Marin
let TextFile;
function getFile(){
return fetch(myText)
.then((response)=>response.text())
.then((text)=>console.log(text))
.then((text)=>TextFile=text)
}
getFile();
console.log(TextFile);