I need to make a function to load a text file, in a Windows Universal JavaScript app, that returns a string not a "promise".
This code will return a "promise" not a string, so is there a way to embed this in a function (that will wait and then return a string), or a complete other way to go about loading a file.
function getFileContentAsync(fileName) {
var fileName = new Windows.Foundation.Uri("ms-appx:///" + fileName);
return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(fileName).then(function (file) {
return Windows.Storage.FileIO.readTextAsync(file);
});
});
//usage
getFileContentAsync(filename).then(function(fileContent){
...
});
I need a function that will receive a fileName and return a String;