Rename getProducts to getProductsAsync for clarity

Updated the `getProducts` function in `product-service.ts` to `getProductsAsync` to reflect its asynchronous nature. Adjusted the import in `products-view.tsx` accordingly and modified the `useEffect` hook in `ProductsView` to utilize the new function, ensuring proper handling of asynchronous requests.
This commit is contained in:
tekh 2025-07-02 17:07:57 +02:00
parent 0acdfdb1eb
commit 786c9e13f0
2 changed files with 3 additions and 3 deletions

View File

@ -13,7 +13,7 @@ export type Product = {
* send a request to the server to get the products * send a request to the server to get the products
* @returns Array of products * @returns Array of products
*/ */
export function getProducts(): Promise<Product[]> { export function getProductsAsync(): Promise<Product[]> {
//TODO: Implement the API call using fetch or axios //TODO: Implement the API call using fetch or axios
return Promise.resolve([ return Promise.resolve([
{ {

View File

@ -7,7 +7,7 @@ import Typography from '@mui/material/Typography';
import { _products } from 'src/_mock'; import { _products } from 'src/_mock';
import { DashboardContent } from 'src/layouts/dashboard'; import { DashboardContent } from 'src/layouts/dashboard';
import { getProducts, Product } from 'src/api/product-service'; import { getProductsAsync, Product } from 'src/api/product-service';
import { ProductSort } from '../product-sort'; import { ProductSort } from '../product-sort';
import { ProductItem } from '../product-item'; import { ProductItem } from '../product-item';
@ -88,7 +88,7 @@ export function ProductsView() {
); );
useEffect(() => { useEffect(() => {
getProducts().then((res) => { getProductsAsync().then((res) => {
setProducts(res); setProducts(res);
}); });
}, []); }, []);