Next.js Discord

Discord Forum

"Too many requests", how to prevent a user from doing too many page refreshes?

Unanswered
Ocicat posted this in #help-forum
Open in Discord
Avatar
OcicatOP
I'm building a dashboard using the Spotify API, I've created the fetching function in a file called data.ts, used it in the page.tsx file of the route and passed down the data to the components of the page as props.
First, is this the correct way to do it?
Then, if the user refreshes multiple times the same page, will this trigger the fetch function every time? This will give a 429 error.

3 Replies

Avatar
Yi Lon Ma
You should cache the data so you don't hit spotify's api again and again
Avatar
OcicatOP
So static rendering? cache all the data that I'm getting through the fetch function in the different pages?
I thought that static rendering is not good for dashboards since you have to show the updates and the latest data available. For example I have a table that shows the recently played songs.
Avatar
Yi Lon Ma
you can use unstable_cache