upload files
, click create new file
- give it a name and copy/paste the code in there
const fetchAllProducts = async () => {
const productsList = [];
const categories = await GetActiveCategories();
const categoriesIdArray = categories.map(category => category.CategoryId);
categoriesIdArray.forEach(async categoryID => {
const response = await getSearchResults(" ", categoryID);
productsList.push(...response);
});
return productsList;
}
const hotDeals = async () => {
const products = await fetchAllProducts();
return products.forEach(product => product.MRP/product.SellingPrice > .8)
}
Promise.all
.map
, without async/await
return Promise.all(categoriesIdArray.map(categoryID => getSearchResults(' ', categoryID)));
const fetchAllProducts = async () => {
const categories = await GetActiveCategories();
const categoriesIdArray = categories.map(category => category.CategoryId);
return Promise.all(categoriesIdArray.map(categoryID => getSearchResults(' ', categoryID)));
}
is this enough, this is still returning a promise