feat(examples): worked example for apis blocks
This commit is contained in:
@@ -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>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user