File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { API , APIParams , APIPath } from 'common/api/schema'
2- import { typedAPICall } from 'common/util/api'
3- import { sleep } from 'common/util/time'
4- import { auth } from './firebase/users'
5- export { APIError } from 'common/api/utils'
1+ import { API , APIParams , APIPath } from 'common/api/schema'
2+ import { typedAPICall } from 'common/util/api'
3+ import { sleep } from 'common/util/time'
4+ import { auth } from './firebase/users'
5+ import toast from "react-hot-toast" ;
6+ import { APIError } from "common/api/utils" ;
67
78export async function api < P extends APIPath > (
89 path : P ,
@@ -21,7 +22,12 @@ export async function api<P extends APIPath>(
2122 }
2223 }
2324
24- return typedAPICall ( path , params , auth . currentUser )
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.' )
29+ throw e
30+ }
2531}
2632
2733function curriedAPI < P extends APIPath > ( path : P ) {
You can’t perform that action at this time.
0 commit comments