diff --git a/api/api/random-color-theme.ts b/api/api/random-color-theme.ts index 813b50f..61cd04c 100644 --- a/api/api/random-color-theme.ts +++ b/api/api/random-color-theme.ts @@ -70,11 +70,7 @@ export default async function handler(request: Request) { }) const _id = 'theme' const patch = client.patch(_id).set(generateThemeColors()) - await Promise.allSettled([ - client.transaction().createIfNotExists({_id, _type: _id}).patch(patch).commit(), - // Wait 3 seconds to stagger requests a little bit - new Promise((resolve) => setTimeout(resolve, 3_000)), - ]) + client.transaction().createIfNotExists({_id, _type: _id}).patch(patch).commit() return new Response(JSON.stringify({patch}), {status: 200, headers}) } catch (err) { diff --git a/tanstack-start/app/components/ThemeButton.tsx b/tanstack-start/app/components/ThemeButton.tsx index 1e96d99..7970d3f 100644 --- a/tanstack-start/app/components/ThemeButton.tsx +++ b/tanstack-start/app/components/ThemeButton.tsx @@ -5,6 +5,10 @@ const randomColorTheme = createServerFn().handler(async () => { const res = await fetch('https://lcapi-examples-api.sanity.dev/api/random-color-theme', { method: 'PUT', }) + + // Wait 3 seconds to stagger requests a little bit + await new Promise((resolve) => setTimeout(resolve, 3_000)) + return res.json() })