i am new to NextJs and I'm tryin to make an app that every few hours make some requests to a database to update the data, but i can't figure out how to do it. The only place where i can do it is inside the pages components, but that means that there has to be a request from a client in order to trigger the update script but i want it to be executed continuously when the server starts and every few hours after that.
I think you have two options you can either use vercel's cron method. https://vercel.com/docs/concepts/solutions/cron-jobs
What I'm more comfortable with is, using some setInterval logic inside my app.ts (app.js) where its mere a express server starting point. It will keep fetching the data with setInterval. we might use some pm2logic here as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With