1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/test/ecmascript/assert/fetch.html
Witold Filipczyk 31e4eb240a [spidermonkey] polyfilled fetch
fetch.js code from https://github.com/JakeChampion/fetch
modified to pass test assertion.
Module import in spidermonkey based on examples.
2024-07-03 20:25:11 +02:00

23 lines
449 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");
getData().then(text => {
console.assert(text === 'Hello', 'hello');
console.exit();
});
</script>