!async function(){ let data = await fetch(location.protocol + "/api") .then((response) => response.text()) .then(data => { return data; }) .catch(error => { console.error(error); }); console.log(data); print(data); }(); function print(data) { document.getElementById("text").innerText = data document.getElementById("text").value = data }