Skip to content

Commit

Permalink
fix: Handle error retrieving endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyjones committed Oct 5, 2023
1 parent ff7747a commit cab8c4a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/api/neighborhoods/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ export function NeighborhoodProvider({ children }: { children: ReactNode }) {
if (!context.query || !context.query.base) {
return;
}
const { endpoints } = await context.query.base.endpoints();
const updated = endpoints
.map((endpoint: string) => endpoint.split(".")[0])
.reduce((acc: Set<string>, val: string) => acc.add(val), new Set());
const updated = new Set<string>();
try {
const { endpoints } = await context.query.base.endpoints();
endpoints
.map((endpoint: string) => endpoint.split(".")[0])
.forEach((service: string) => updated.add(service));

Check warning on line 72 in src/api/neighborhoods/provider.tsx

View check run for this annotation

Codecov / codecov/patch

src/api/neighborhoods/provider.tsx#L67-L72

Added lines #L67 - L72 were not covered by tests
} catch (error) {
console.error(`Couldn't update services: ${(error as Error).message}`);

Check warning on line 74 in src/api/neighborhoods/provider.tsx

View check run for this annotation

Codecov / codecov/patch

src/api/neighborhoods/provider.tsx#L74

Added line #L74 was not covered by tests
}
setServices(updated);

Check warning on line 76 in src/api/neighborhoods/provider.tsx

View check run for this annotation

Codecov / codecov/patch

src/api/neighborhoods/provider.tsx#L76

Added line #L76 was not covered by tests
}
updateServices();
Expand Down

0 comments on commit cab8c4a

Please sign in to comment.