now with dynamic counter too
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
<div>
|
||||
|
||||
<button onclick={loadCard}>Load Card</button>
|
||||
<button id="nextbtn" onclick={loadCard}>Load Card</button>
|
||||
|
||||
{#each cards as card}
|
||||
<article>
|
||||
|
||||
23
svelte/my-app/src/routes/count/+page.svelte
Normal file
23
svelte/my-app/src/routes/count/+page.svelte
Normal file
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let count = null;
|
||||
|
||||
async function loadNext() {
|
||||
const response = await fetch('http://127.0.0.1:9000/next_json');
|
||||
count = (await response.json()).count;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
loadNext();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
||||
<button id="nextbtn" onclick={loadNext}>Load Next</button>
|
||||
|
||||
{#if count}
|
||||
<p>Count: {count}</p>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user