(getter, attempts = 3)
| 10 | }; |
| 11 | |
| 12 | async function tryRequest(getter, attempts = 3) { |
| 13 | let lastError; |
| 14 | for (let attempt = 1; attempt <= attempts; attempt++) { |
| 15 | try { |
| 16 | return await getter(); |
| 17 | } catch (err) { |
| 18 | lastError = err; |
| 19 | if (attempt < attempts) { |
| 20 | await new Promise(r => setTimeout(r, 1000 * attempt)); |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | throw lastError; |
| 25 | } |
| 26 | |
| 27 | // EliteProTech API - Primary |
| 28 | async function getEliteProTechVideoByUrl(youtubeUrl) { |
no outgoing calls
no test coverage detected