Fix too many request on atinternet api

pull/2313/head
Jérémy Rialland 2022-10-06 12:23:34 +02:00 committed by Jérémy Rialland
parent 48cda785d0
commit d31e418693
1 changed files with 5 additions and 0 deletions

View File

@ -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})`)
}