composition-api icon indicating copy to clipboard operation
composition-api copied to clipboard

feat: multiple `fetchState`

Open edumudu opened this issue 3 years ago • 1 comments

🆒 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 avatar Jun 17 '21 18:06 edumudu

@edumudu https://github.com/nuxt-community/composition-api/blob/4c3e73426c4bc78127bca5393b05be4fec65f369/src/runtime/composables/fetch.ts#L86

roberthgnz avatar Sep 05 '21 12:09 roberthgnz