You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extract a fetchJson helper for throw-on-error fetches (#193)
The data-fetching hooks/components repeated the same "await fetch, check
response.ok, otherwise throw `<label> failed (HTTP <status>)`, then parse
JSON" boilerplate. Extract it into `fetchJson<T>` in utils/api.ts and use
it at the five sites that share those exact semantics:
- ChartView: compound_svg POST and the chart-data GET (the AbortController
signal is passed straight through; AbortError still propagates).
- MainDatasetView: dataset-metadata react-query queryFn.
- useSearchTask: the submit_query call.
- MainSelectedSet: the /reactions POST.
Sites that deliberately *swallow* errors are intentionally left alone:
MainReactionView, CompoundView, ReactionCard, and ModalKetcher return
null/'' (or warn) on a bad response so an HTML error body never reaches
dangerouslySetInnerHTML, and useSearchTask's poll branches on specific
200/202 status codes. Those don't fit a throw-on-error helper.
No behavior change at the migrated sites; `npm run build` (tsc + vite)
and `npm run lint` pass.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments