Skip to content

Commit

Permalink
feat: retry ecosystem request every 10s
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco committed Jan 2, 2025
1 parent 8ba9df6 commit 8c83a7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export const contractsMachine = createMachine(
},
},
failure: {
type: 'final',
after: {
10000: 'fetching',
},
},
success: {
type: 'final',
Expand All @@ -64,7 +66,8 @@ export const contractsMachine = createMachine(
null,
MachineServices['fetchProjects']['data']
>({
showError: true,
showError: false,
maxAttempts: 1,
async fetch() {
return EcosystemService.fetchProjects();
},
Expand Down
11 changes: 7 additions & 4 deletions packages/app/src/systems/Ecosystem/services/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { ECOSYSTEM_PROJECTS_URL } from '~/config';
// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export class EcosystemService {
static async fetchProjects() {
const data = (await (
await fetch(ECOSYSTEM_PROJECTS_URL)
).json()) as Array<EcosystemProject>;
const res = await fetch(ECOSYSTEM_PROJECTS_URL);

return data;
if (res.ok) {
const data: EcosystemProject[] = await res.json();
return data;
}

return [];
}
}

0 comments on commit 8c83a7a

Please sign in to comment.