Created
July 30, 2024 21:41
-
-
Save wealthfront-data-fetching-blog-post/f313e770c9c7efb7231bd5215d9b3a68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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