|
|
@ -1,6 +1,4 @@
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
let promise = getRandomNumber();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getRandomNumber() {
|
|
|
|
async function getRandomNumber() {
|
|
|
|
const res = await fetch(`tutorial/random-number`);
|
|
|
|
const res = await fetch(`tutorial/random-number`);
|
|
|
|
const text = await res.text();
|
|
|
|
const text = await res.text();
|
|
|
@ -11,6 +9,8 @@
|
|
|
|
throw new Error(text);
|
|
|
|
throw new Error(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let promise = getRandomNumber();
|
|
|
|
|
|
|
|
|
|
|
|
function handleClick() {
|
|
|
|
function handleClick() {
|
|
|
|
promise = getRandomNumber();
|
|
|
|
promise = getRandomNumber();
|
|
|
@ -27,4 +27,4 @@
|
|
|
|
<p>The number is {number}</p>
|
|
|
|
<p>The number is {number}</p>
|
|
|
|
{:catch error}
|
|
|
|
{:catch error}
|
|
|
|
<p style="color: red">{error.message}</p>
|
|
|
|
<p style="color: red">{error.message}</p>
|
|
|
|
{/await}
|
|
|
|
{/await}
|
|
|
|