I am trying to read a locally stored text file using javascript. I need to pass the information stored on the text file to pass through evaluations for test result. Since I could not access the text file directly, I have hosted it on to a local server and trying to fetch data using the URL.
Here is how my code looks like -
const mediaFile = 'http://localhost:8080/' + fileName;
function MediaInfo(file) {
fetch(file)
.then(function (response) {
response.text();
})
.then(function (data) {
console.log(data);
return response.data();
});
}
const a = MediaInfo(mediaFile);
await browser.expect(a).eql(44);
});
But the calling of function MediaInfo(mediaFile) returns undefined. Any idea why I cant get the data returned??