diff --git a/src/pages/SignWithCosmos.tsx b/src/pages/SignWithCosmos.tsx index 2d62ffa..b8c6661 100644 --- a/src/pages/SignWithCosmos.tsx +++ b/src/pages/SignWithCosmos.tsx @@ -54,19 +54,24 @@ const SignWithCosmos = () => { address: cosmosAddress, }), }); - - if (response.status === 429) { - const errorResponse = await response.json(); - enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" }); - setIsRequesting(false); - throw new Error('Failed to send request'); + + if (response.ok) { + enqueueSnackbar('Tokens sent successfully', { variant: "success" }); + } else { + if (response.status === 429) { + const errorResponse = await response.json(); + enqueueSnackbar(`${response.statusText} : ${errorResponse.error}`, { variant: "error" }); + setIsRequesting(false); + } else { + throw new Error('Failed to send request'); + } } getBalances(); setIsRequesting(false); - enqueueSnackbar('Tokens sent successfully', { variant: "success" }); } catch (error) { console.error('Error:', error); + throw error; } };