Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wealthfront-data-fetching-blog-post/f313e770c9c7efb7231bd5215d9b3a68 to your computer and use it in GitHub Desktop.
Save wealthfront-data-fetching-blog-post/f313e770c9c7efb7231bd5215d9b3a68 to your computer and use it in GitHub Desktop.
// simplified
function useApiQuery(endpointName, params, options) {
const { onError, ...restOptions } = options ?? {};
return useQuery({
queryKey: [endpointName, ...params],
queryFn: () => {
return api[endpointName].apply(null, params);
},
onError: (e) => {
alertErrorMonitoring(e);
onError?.(e);
},
...restOptions,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment