Files
iNaturalistReactNative/src/sharedHooks/useQuery.ts
Amanda Bullington 5945ccc525 Fixes and error handling for API throttling (#1971)
* Add new error type for 429; remove unnecessary logs

* Batch API calls for SpeciesSeenCheckmark

* Remove SpeciesSeenCheckmark test

* Revert logging errors

* Use Set for observedTaxonIds

* Add comments around logger.info statements

* Merge linting update

* More fixes from code review

* Switch to non-authenticated useQuery for fetching taxon ids seen by X user id

* Fix tests
2024-08-14 22:08:03 -07:00

19 lines
571 B
TypeScript

import { useQuery } from "@tanstack/react-query";
import { reactQueryRetry } from "sharedHelpers/logging";
// Should work like React Query's useQuery with our custom reactQueryRetry
const useNonAuthenticatedQuery = (
queryKey: Array<string>,
queryFunction: Function,
queryOptions: Object = {}
): Object => useQuery( {
queryKey: [...queryKey, queryOptions.allowAnonymousJWT],
queryFn: queryFunction,
retry: ( failureCount, error ) => reactQueryRetry( failureCount, error, {
queryKey
} ),
...queryOptions
} );
export default useNonAuthenticatedQuery;