Skip to content

Commit

Permalink
remove forced stagger
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 21, 2024
1 parent 342d408 commit b0c47d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions api/api/random-color-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions tanstack-start/app/components/ThemeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down

0 comments on commit b0c47d2

Please sign in to comment.