Hello Hugo community,
I’m making multiple API calls using the
GetJSON function in my templates. To avoid hitting the rate limits of the API, I need to introduce a delay between the calls.
I’ve explored using the
sleep function, but it seems that it’s not available in Hugo’s templating language.
Is there a recommended way or workaround to introduce a sleep or delay between API calls in Hugo templates? Any guidance or examples would be greatly appreciated.
Thank you in advance for your help!
resources.GetRemote instead, and let us know if you’re still having problems.
We added a re-try to
resources.GetRemote in #11326 to address a similar issue, #11312.
I imagine we will deprecate both
data.GetCSV at some point.
Thanks!. I changed the code to use resources.GetRemote and I no longer get rate limit errors.
The error I’m getting now is :
Error calling resources.GetRemote: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Any suggestion on how to approach this?
The client timeout is (hardcoded) to 1 minute, but that’s per request, so should be … plenty?