fix(API): remove unused user_id parameter in getApiKey function
fix(API): remove unused user_id parameter in createApiKey function and add name parameter fix(API): change deleteApiKey parameter from user_id to api_key fix(SecretKeyModal): change createApiKey parameter from data to apiKeyName fix(ApiKeysPage): remove unused user_id parameter in getApiKey function and add console.log for debugging
This commit is contained in:
parent
a31d1f104d
commit
5efdde4aca
3 changed files with 9 additions and 8 deletions
|
|
@ -466,9 +466,9 @@ export async function updateUser(user_id: string, user: Users) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getApiKey(user_id: String) {
|
||||
export async function getApiKey() {
|
||||
try {
|
||||
const res = await api.get(`${BASE_URL_API}api_key/${user_id}`);
|
||||
const res = await api.get(`${BASE_URL_API}api_key`);
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
@ -478,9 +478,9 @@ export async function getApiKey(user_id: String) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function createApiKey(user_id: string) {
|
||||
export async function createApiKey(name:string) {
|
||||
try {
|
||||
const res = await api.post(`${BASE_URL_API}api_key/${user_id}`);
|
||||
const res = await api.post(`${BASE_URL_API}api_key`,{name});
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
@ -491,9 +491,9 @@ export async function createApiKey(user_id: string) {
|
|||
}
|
||||
|
||||
|
||||
export async function deleteApiKey(user_id: string) {
|
||||
export async function deleteApiKey(api_key: string) {
|
||||
try {
|
||||
const res = await api.delete(`${BASE_URL_API}api_key/${user_id}`);
|
||||
const res = await api.delete(`${BASE_URL_API}api_key/${api_key}`);
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export default function SecretKeyModal({
|
|||
};
|
||||
|
||||
function handleAddNewKey() {
|
||||
createApiKey(data)
|
||||
createApiKey(apiKeyName)
|
||||
.then((res) => {
|
||||
setApiKeyValue(res["api_key"]);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export default function ApiKeysPage() {
|
|||
function getKeys() {
|
||||
setLoadingKeys(true);
|
||||
if (userData) {
|
||||
getApiKey(userData.id)
|
||||
getApiKey()
|
||||
.then((keys: [ApiKey]) => {
|
||||
keysList.current = keys["api_keys"];
|
||||
setUserId(keys["user_id"]);
|
||||
|
|
@ -196,6 +196,7 @@ export default function ApiKeysPage() {
|
|||
data={api_keys.id}
|
||||
index={index}
|
||||
onConfirm={(index, keys) => {
|
||||
console.log(keys);
|
||||
handleDeleteKey(keys);
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue