composition-api
composition-api copied to clipboard
feat: multiple `fetchState`
🆒 Your use case
When using multiple calls to API for different features in the same component, would be nice to each fetchState
returned from useFetch
to were independent. It would help a lot to make independent checks for each session, to be able to make an efficient skeleton loader for example
🆕 The solution you'd like
const { fetch: fetchPosts, fetchState: fetchPostsState } = useFetch(...);
const { fetch: fetchCategories, fetchState: fetchCategoriesState } = useFetch(...);
// fetchPostsState.pending should be true only when `fetchPosts` be called
// fetchCategoriesState.pending should be true only when `fetchCategories` be called
@edumudu https://github.com/nuxt-community/composition-api/blob/4c3e73426c4bc78127bca5393b05be4fec65f369/src/runtime/composables/fetch.ts#L86