From 329dbfc64ccda25b3a3eb4538066aa53ff39692e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 3 Oct 2024 05:27:15 +0530 Subject: [PATCH] feat: notify errors --- src/components/organisms/ApiKey.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/organisms/ApiKey.tsx b/src/components/organisms/ApiKey.tsx index 15c16393..8133ae39 100644 --- a/src/components/organisms/ApiKey.tsx +++ b/src/components/organisms/ApiKey.tsx @@ -40,8 +40,8 @@ const ApiKeyManager = () => { try { const { data } = await axios.get('http://localhost:8080/auth/api-key'); setApiKey(data.api_key); - } catch (error) { - console.error('Error fetching API key', error); + } catch (error: any) { + notify('error', `Failed to fetch API Key - ${error.message}`); } finally { setLoading(false); } @@ -56,8 +56,8 @@ const ApiKeyManager = () => { const { data } = await axios.post('http://localhost:8080/auth/generate-api-key'); setApiKey(data.api_key); notify('success', `Generated API Key successfully`); - } catch (error) { - console.error('Error generating API key', error); + } catch (error: any) { + notify('error', `Failed to generate API Key - ${error.message}`); } finally { setLoading(false); } @@ -69,8 +69,8 @@ const ApiKeyManager = () => { await axios.delete('http://localhost:8080/auth/delete-api-key'); setApiKey(null); notify('success', 'API Key deleted successfully'); - } catch (error) { - console.error('Error deleting API key', error); + } catch (error: any) { + notify('error', `Failed to delete API Key - ${error.message}`); } finally { setLoading(false); }