mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
31e4eb240a
fetch.js code from https://github.com/JakeChampion/fetch modified to pass test assertion. Module import in spidermonkey based on examples.
23 lines
449 B
HTML
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>
|