From 08e02b6ac059c817508c2bfa71685254bab1c3b7 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Thu, 16 Oct 2025 00:28:25 +0200 Subject: [PATCH] Add too many requests toast --- web/lib/api.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/lib/api.ts b/web/lib/api.ts index 051ef622..ba0cee3b 100644 --- a/web/lib/api.ts +++ b/web/lib/api.ts @@ -2,8 +2,8 @@ import {API, APIParams, APIPath} from 'common/api/schema' import {typedAPICall} from 'common/util/api' import {sleep} from 'common/util/time' import {auth} from './firebase/users' -import toast from "react-hot-toast"; import {APIError} from "common/api/utils"; +import toast from "react-hot-toast"; export async function api

( path: P, @@ -22,12 +22,11 @@ export async function api

( } } - try { - return typedAPICall(path, params, auth.currentUser) - } catch (e) { - if (e instanceof APIError && e.code === 429) toast.error('Too many requests. Please try again later.') + return typedAPICall(path, params, auth.currentUser).catch((e) => { + if (e instanceof APIError && e.code === 429) {} + toast.error('Too many requests. Please try again later.') throw e - } + }) } function curriedAPI

(path: P) {