When I do console.log(readTextFile("./yaml/ss.txt"))
it is just undefined.
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
return allText;
}
}
}
}
rawFile.send(null);
console.log(readTextFile("./yaml/ss.txt"))
"./yaml/ss.txt"
is a file and I have tried removing rawFile.send(null);
and changing the return to just return "test";