L
Size: a a a
L
心
A
L
心
Ð
A
Ð
KG
KG
A
KL
async function notSurrender(counter = 1) {
let data;
while (data !== undefined && counter !== 0) {
try {
const response = await fetch(...);
data = await parseResponse(response);
}
catch(e) {
counter--;
console.error(e);
}
}
return data;
}
const Retrieable = async (actionCreator, maxRetries, errorhandler) => {
let attempts = 0;
while(true) {
try {
const res = await actionCreator();
return res;
} catch (error) {
if (attempts === maxRetries) throw error;
await errorhandler(error);
attempts++;
}
}
};
Retrieable(() => fetch(), 10, () => sleep(100))
Ð
A
Ð
A
KG
Ð