From 64aea7f58981a487ffe0e50946eda8692a4d0812 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Wed, 18 Oct 2023 23:33:22 -0300 Subject: [PATCH] feat(API): add function to add an API key to the API key store This commit adds a new function `addApiKeyStore` to the API controller. This function is used to add an API key to the API key store by making a POST request to the `/api_key/store` endpoint with the provided key. If the request is successful (status code 200), the function returns the response data. If there is an error, it is logged to the console and re-thrown. --- src/frontend/src/controllers/API/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index f66233afd..9e86db37c 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -522,3 +522,17 @@ export async function deleteApiKey(api_key: string) { throw error; } } + +export async function addApiKeyStore(key: string) { + try { + const res = await api.post(`${BASE_URL_API}api_key/store`, { + api_key: key, + }); + if (res.status === 200) { + return res.data; + } + } catch (error) { + console.log("Error:", error); + throw error; + } +}