diff --git a/app/api/cron/route.ts b/app/api/cron/route.ts index 03aedf6..ba4706b 100644 --- a/app/api/cron/route.ts +++ b/app/api/cron/route.ts @@ -11,7 +11,7 @@ import Product from "@/lib/models/product.model"; import { scrapeAmazonProduct } from "@/lib/scraper"; import { generateEmailBody, sendEmail } from "@/lib/nodemailer"; -export const maxDuration = 60; // This function can run for a maximum of 300 seconds +export const maxDuration = 60; export const dynamic = "force-dynamic"; export const revalidate = 0; diff --git a/app/page.tsx b/app/page.tsx index 6ba6a97..2d12100 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,6 +6,7 @@ import React from 'react' import ProductCard from '@/components/ProductCard'; const Home = async () => { + const allProducts = await getAllProducts(); return ( diff --git a/lib/actions/index.ts b/lib/actions/index.ts index 2fc0acf..75ce674 100644 --- a/lib/actions/index.ts +++ b/lib/actions/index.ts @@ -65,13 +65,12 @@ export async function getProductById(productId: string) { export async function getAllProducts() { try { - connectToDB(); + await connectToDB(); const products = await Product.find(); - console.log(products); - return products; + } catch (error) { console.log(error); }