feat(StorePage): update search data when fetching store components to ensure accurate search results

fix(StorePage): set search data to an empty array when an error occurs to prevent displaying incorrect search results
This commit is contained in:
cristhianzl 2023-10-23 22:24:59 -03:00
commit 64b1945cbc

View file

@ -55,12 +55,13 @@ export default function StorePage(): JSX.Element {
setLoading(true); setLoading(true);
getStoreComponents(1, 10) getStoreComponents(1, 10)
.then((res) => { .then((res) => {
console.log(res); setSearchData(res);
setLoading(false); setLoading(false);
setErrorApiKey(false); setErrorApiKey(false);
setData(res); setData(res);
}) })
.catch((err) => { .catch((err) => {
setSearchData([]);
setLoading(false); setLoading(false);
setErrorApiKey(true); setErrorApiKey(true);
setErrorData({ setErrorData({