feat(examples): worked example for apis blocks

This commit is contained in:
2026-08-20 08:36:03 +05:30
parent 0ed8351828
commit 63316111cb
2 changed files with 18 additions and 0 deletions
@@ -21,6 +21,11 @@ page ApiBlockDemo {
}
}
load server serverSearch {
const users = await api.searchDirectory({ name: "a" })
return { names: users.map((user) => user.name).join(", ") }
}
functions {
client async function search(): Promise<void> {
const users = await api.searchDirectory({ name: nameFilter })
@@ -33,6 +38,12 @@ page ApiBlockDemo {
<button @click="search()">Search</button>
<p class="found" data-text="found">{found}</p>
<p class="failed" data-text="failed">{failed}</p>
<Async source="serverSearch">
<Loading><p class="server-found">Loading…</p></Loading>
<Success data="serverSearch"><p class="server-found">{serverSearch.names}</p></Success>
<Error error="error"><p class="server-found">Failed: {error.message}</p></Error>
</Async>
<p class="bound" api="searchDirectory({ name: 'a' })">loading</p>
</main>
}
}