I've two files.
FILE 1:
<!DOCTYPE html>
<html>
<body>
<button class="add">Click Here!</button>
<script>
let a;
async function test(file) {
let response = await fetch(file);
return response.text();
}
const bu = document.querySelector(".add");
bu.addEventListener("click", async () => {
a = test("./prova.html");
console.log(a);
});
</script>
</body>
</html>
FILE 2:
<h1>Hello, World!</h1>
When I click the button I want to pass the text body of response from fetch to the var a. But what i get instead is
index.html:16 Promise {<pending>}