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:
parent
0acdfdb1eb
commit
786c9e13f0
@ -13,7 +13,7 @@ export type Product = {
|
||||
* send a request to the server to get the products
|
||||
* @returns Array of products
|
||||
*/
|
||||
export function getProducts(): Promise<Product[]> {
|
||||
export function getProductsAsync(): Promise<Product[]> {
|
||||
//TODO: Implement the API call using fetch or axios
|
||||
return Promise.resolve([
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ import Typography from '@mui/material/Typography';
|
||||
|
||||
import { _products } from 'src/_mock';
|
||||
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 { ProductItem } from '../product-item';
|
||||
@ -88,7 +88,7 @@ export function ProductsView() {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
getProducts().then((res) => {
|
||||
getProductsAsync().then((res) => {
|
||||
setProducts(res);
|
||||
});
|
||||
}, []);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user