Next.js Discord

Discord Forum

Dev mode caused me to be rate-limited/temp banned from Discord API?

Answered
Swyftey posted this in #help-forum
Open in Discord
Hi,

I am working in NextJS’s dev mode and I think it is known to do some stuff and possibly call an API multiple times, but if that’s the case, it ended up getting me temporarily-banned from the Discord API on my computer.

What can I do to prevent this? All I’ve been doing is calling a Discord endpoint in a useEffect hook (and then switched to server-fetch).
Answered by Yi Lon Ma
calling APIs with ratelimit in useeffect is a bad idea in general
View full answer

7 Replies

Got a semi-answer somewhere, but it would help if someone knows of a good way to prevent an API from potentially being spammed in dev mode
calling APIs with ratelimit in useeffect is a bad idea in general
Answer
but if you have to do it
search for useEffectOnce on google and add that custom hook
it uses refs to bypass dual render in strict mode
but you can't stop it from calling the API again on each save
Thank you