🐛 fix(API/index.ts): add return type to getStoreComponents function to improve code readability and maintainability
🐛 fix(StorePage/index.tsx): fix comment syntax error to prevent code from being commented out 🐛 fix(StorePage/index.tsx): handle undefined response in getStoreComponents promise chain to prevent errors
This commit is contained in:
parent
7811999c24
commit
c9d22071cd
2 changed files with 4 additions and 5 deletions
|
|
@ -594,7 +594,7 @@ export async function getStoreComponents(
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
limit: number = 10,
|
limit: number = 10,
|
||||||
is_component?: boolean | null
|
is_component?: boolean | null
|
||||||
) {
|
): Promise<StoreComponentResponse | undefined> {
|
||||||
try {
|
try {
|
||||||
let url = `${BASE_URL_API}store/components/`;
|
let url = `${BASE_URL_API}store/components/`;
|
||||||
const queryParams: any = [];
|
const queryParams: any = [];
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,9 @@ export default function StorePage(): JSX.Element {
|
||||||
|
|
||||||
getStoreComponents(index - 1, size, filterComponent.current)
|
getStoreComponents(index - 1, size, filterComponent.current)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setSearchData(res.results);
|
setSearchData(res?.results ?? []);
|
||||||
setTotalRowsCount(Number(res.count));
|
setTotalRowsCount(Number(res?.count ?? 0));
|
||||||
setErrorApiKey(true);
|
setErrorApiKey(true);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue