get notes added
This commit is contained in:
parent
4400cbc69e
commit
96d26ce568
|
@ -19,6 +19,21 @@
|
|||
alert('Failed to create note');
|
||||
}
|
||||
}
|
||||
|
||||
let notes = [];
|
||||
|
||||
async function fetchNotes() {
|
||||
const response = await fetch('http://localhost:8069/notes');
|
||||
|
||||
if (response.ok) {
|
||||
notes = await response.json();
|
||||
} else {
|
||||
console.error('Failed to fetch notes');
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch notes when the component is first rendered
|
||||
fetchNotes();
|
||||
</script>
|
||||
|
||||
|
||||
|
@ -32,4 +47,12 @@
|
|||
</ul>
|
||||
|
||||
<input bind:value={text} type="text" placeholder="Enter note text" />
|
||||
<button on:click={createNote}>Create Note</button>
|
||||
<button on:click={createNote}>Create Note</button>
|
||||
|
||||
<button on:click={fetchNotes}>Refresh Notes</button>
|
||||
|
||||
<ul>
|
||||
{#each notes as note}
|
||||
<li>{note.Text}</li>
|
||||
{/each}
|
||||
</ul>
|
Loading…
Reference in New Issue