[PIE-28] Switch to type-safe API (#12)
Custom API client to handle a lot of the more type safe queries Reviewed-on: #12 Co-authored-by: june <self@breadone.net> Co-committed-by: june <self@breadone.net>
This commit was merged in pull request #12.
This commit is contained in:
@@ -1,17 +1,7 @@
|
||||
---
|
||||
import client from "@/data/pocketbase";
|
||||
const { class: className, recipe } = Astro.props
|
||||
|
||||
async function getLink(img: string) {
|
||||
const record = await client.collection("images").getOne(img)
|
||||
const link = await client.files.getRelativeURL(record, record.image)
|
||||
return link
|
||||
}
|
||||
|
||||
// Use Promise.all to wait for all async operations to complete
|
||||
const links = await Promise.all(
|
||||
recipe.images.map((img: string) => getLink(img))
|
||||
)
|
||||
const links = await client.getRecipeImages(recipe as string)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user