Re-run the code if a specific error appears

I'm receiving this error:
Error: lexical error: invalid char in json text. <!DOCTYPE html PUBLIC "-//W3C// (right here) ------^
The code uses an API to download series from the world bank. As the page sometimes fails, I think the problem appears there (sometimes the code runs perfect and other I receive that error, but in different moments).
I want to give the instruction that in case this error appear, wait for 30 second and try again (instead of stop running).
Any idea of how to do something like that would be much appreciated

I would use purrr's insistently()

Thanks a lot for the suggestion! I will try with that

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.