javascript fetch return promise instead of the content of the file

Viewed 13

I am having an issue with returning a value from an async function.

Here is my code:

async function readMyFile(url)
{

    let response=await fetch(url);
    let myText=await response.text();

    return myText;
}


console.log(readMyFile('gangina.txt'));

The console output is :

Promise { <state>: "pending" }

Inside of that I can get the text content but under <value> section but I need ONLY the text content.

I guess minor tweak needed here.

Thank you very much in advance.

0 Answers
Related