fix(storeContext.tsx): fix setLoadingApiKey not being called in catch block to stop loading state

fix(API/index.ts): fix BASE_URL_API missing slash causing incorrect API endpoint URL
fix(StorePage/index.tsx): add catch block to handle error when fetching store tags and log error message
This commit is contained in:
anovazzi1 2023-11-20 19:29:39 -03:00
commit d9aeb6b79c
3 changed files with 12 additions and 6 deletions

View file

@ -47,6 +47,7 @@ export function StoreProvider({ children }) {
setValidApiKey(res?.is_valid ?? false);
setLoadingApiKey(false);
} catch (e) {
setLoadingApiKey(false);
console.log(e);
}
};

View file

@ -732,7 +732,7 @@ export async function searchComponent(
export async function checkHasApiKey() {
try {
const res = await api.get(`${BASE_URL_API}/store/check/api_key`);
const res = await api.get(`${BASE_URL_API}store/check/api_key`);
if (res?.status === 200) {
return res.data;
}

View file

@ -57,7 +57,7 @@ export default function StorePage(): JSX.Element {
"You don't have an API Key. Please add one to use the Langflow Store.",
],
});
setLoading(false)
setLoading(false);
} else if (!validApiKey) {
setErrorData({
title: "API Key Error",
@ -87,10 +87,15 @@ export default function StorePage(): JSX.Element {
function handleGetTags() {
setLoadingTags(true);
getStoreTags().then((res) => {
setTags(res);
setLoadingTags(false);
});
getStoreTags()
.then((res) => {
setTags(res);
setLoadingTags(false);
})
.catch((err) => {
console.log(err);
setLoadingTags(false);
});
}
function handleGetComponents() {