Skip to content

Commit 08e02b6

Browse files
committed
Add too many requests toast
1 parent 715811d commit 08e02b6

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

web/lib/api.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {API, APIParams, APIPath} from 'common/api/schema'
22
import {typedAPICall} from 'common/util/api'
33
import {sleep} from 'common/util/time'
44
import {auth} from './firebase/users'
5-
import toast from "react-hot-toast";
65
import {APIError} from "common/api/utils";
6+
import toast from "react-hot-toast";
77

88
export async function api<P extends APIPath>(
99
path: P,
@@ -22,12 +22,11 @@ export async function api<P extends APIPath>(
2222
}
2323
}
2424

25-
try {
26-
return typedAPICall(path, params, auth.currentUser)
27-
} catch (e) {
28-
if (e instanceof APIError && e.code === 429) toast.error('Too many requests. Please try again later.')
25+
return typedAPICall(path, params, auth.currentUser).catch((e) => {
26+
if (e instanceof APIError && e.code === 429) {}
27+
toast.error('Too many requests. Please try again later.')
2928
throw e
30-
}
29+
})
3130
}
3231

3332
function curriedAPI<P extends APIPath>(path: P) {

0 commit comments

Comments
 (0)