1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00
elinks/test/ecmascript/assert/fetch.html
2024-07-08 21:32:38 +02:00

34 lines
578 B
HTML

<script>
async function getData() {
const url = "hello.html";
try {
const response = await fetch(url);
if (!response.ok) {
console.error(`Response status: ${response.status}`);
}
const txt = await response.text();
return txt;
} catch (error) {
console.error(error.message);
}
}
console.error("fetch.html");
var ex = 0;
getData().then(text => {
console.assert(text === 'Hello', 'hello');
ex = 1;
});
function loop()
{
if (ex == 1) {
setTimeout(console.exit());
} else {
setTimeout(loop, 1);
}
}
loop();
</script>