Skip to content

Commit 1728d93

Browse files
committed
Fix mutate timing
1 parent 07313e9 commit 1728d93

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

site/api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,16 @@ export namespace Workspace {
9393
})
9494

9595
const body = await response.json()
96-
await mutate("/api/v2/workspaces")
97-
await mutate("/api/v2/projects")
9896
if (!response.ok) {
9997
throw new Error(body.message)
10098
}
10199

100+
// Let SWR know that both the /api/v2/workspaces/* and /api/v2/projects/*
101+
// endpoints will need to fetch new data.
102+
const mutateWorkspacesPromise = mutate("/api/v2/workspaces")
103+
const mutateProjectsPromise = mutate("/api/v2/projects")
104+
await Promise.all([mutateWorkspacesPromise, mutateProjectsPromise])
105+
102106
return body
103107
}
104108
}

0 commit comments

Comments
 (0)