Created
April 16, 2026 20:16
-
-
Save antlis/764f333147afdd4bb175d610222db826 to your computer and use it in GitHub Desktop.
Safer wrapper around useAsyncData with sensible defaults to avoid duplicate requests and undefined state issues.
This file contains hidden or 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
| export function useAsyncDataSafe<T>( | |
| key: string, | |
| handler: () => Promise<T> | |
| ) { | |
| return useAsyncData<T>(key, handler, { | |
| server: true, | |
| lazy: false, | |
| default: () => null, | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment