From d31e4186931588b48851dac7a4ae14f3bee58264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 6 Oct 2022 12:23:34 +0200 Subject: [PATCH] Fix too many request on atinternet api --- site/scripts/fetch-stats.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/site/scripts/fetch-stats.js b/site/scripts/fetch-stats.js index 41bbc10ba..f37c4a5eb 100644 --- a/site/scripts/fetch-stats.js +++ b/site/scripts/fetch-stats.js @@ -22,6 +22,11 @@ const fetchApi = async function (query) { body: JSON.stringify(query), }) if (!response.ok) { + if (response.status === 429) { + return new Promise((resolve) => + setTimeout(() => resolve(fetchApi(query)), 100) + ) + } const text = await response.text() throw new Error(`Erreur de l'API (${text})`) }