Handling errors on get component
This commit is contained in:
parent
340a0b4431
commit
364c461269
1 changed files with 22 additions and 12 deletions
|
|
@ -55,6 +55,13 @@ export default function StorePage(): JSX.Element {
|
||||||
"You don't have an API Key. Please add one to use the Langflow Store.",
|
"You don't have an API Key. Please add one to use the Langflow Store.",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
} else if (!validApiKey) {
|
||||||
|
setErrorData({
|
||||||
|
title: "API Key Error",
|
||||||
|
list: [
|
||||||
|
"Your API Key is not valid. Please add a valid API Key to use the Langflow Store.",
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [loadingApiKey, validApiKey, hasApiKey]);
|
}, [loadingApiKey, validApiKey, hasApiKey]);
|
||||||
|
|
@ -97,11 +104,13 @@ export default function StorePage(): JSX.Element {
|
||||||
filterByUser: selectFilter === "createdbyme" && validApiKey ? true : null,
|
filterByUser: selectFilter === "createdbyme" && validApiKey ? true : null,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res?.authorized === false && validApiKey === false) {
|
if (!res?.authorized && validApiKey === true) {
|
||||||
setValidApiKey(false);
|
setValidApiKey(false);
|
||||||
return;
|
setSelectFilter("all");
|
||||||
|
} else {
|
||||||
|
if (res?.authorized) {
|
||||||
|
setValidApiKey(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setSearchData(res?.results ?? []);
|
setSearchData(res?.results ?? []);
|
||||||
setTotalRowsCount(
|
setTotalRowsCount(
|
||||||
|
|
@ -109,6 +118,7 @@ export default function StorePage(): JSX.Element {
|
||||||
? Number(res?.count ?? 0)
|
? Number(res?.count ?? 0)
|
||||||
: res?.results?.length ?? 0
|
: res?.results?.length ?? 0
|
||||||
);
|
);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.response.status === 403 || err.response.status === 401) {
|
if (err.response.status === 403 || err.response.status === 401) {
|
||||||
|
|
@ -344,8 +354,8 @@ export default function StorePage(): JSX.Element {
|
||||||
<div className="flex w-full flex-col gap-4">
|
<div className="flex w-full flex-col gap-4">
|
||||||
<div className="grid w-full gap-4">
|
<div className="grid w-full gap-4">
|
||||||
You haven't{" "}
|
You haven't{" "}
|
||||||
{selectFilter === "createdbyme" ? "crafted" : "liked"} any
|
{selectFilter === "createdbyme" ? "created" : "liked"} any
|
||||||
flows yet. Why not give it a shot and create one? :)
|
flows yet.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue