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.
This commit is contained in:
parent
d66944ae7e
commit
64aea7f589
1 changed files with 14 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue