MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / fetchWithRetries

Function fetchWithRetries

plugins/why.js:2–17  ·  view source on GitHub ↗
(url, retries = 3, delay = 2000)

Source from the content-addressed store, hash-verified

1import axios from 'axios';
2async function fetchWithRetries(url, retries = 3, delay = 2000) {
3 let attempt = 0;
4 while (attempt < retries) {
5 try {
6 const { data } = await axios.get(url);
7 return data;
8 }
9 catch (err) {
10 attempt++;
11 console.error(`[WHY] Attempt ${attempt} failed:`, err.message);
12 if (attempt >= retries)
13 throw new Error('Max retries reached');
14 await new Promise(r => setTimeout(r, delay));
15 }
16 }
17}
18export default {
19 command: 'why',
20 aliases: ['whyme', 'question'],

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected