Ever wanted to benefit from all the cool features of @tanstack/vue-query but your project doesn't use Composition API? Me too. The files below illustrate a crude - but working - implementation that abuses the reactivity of data
in Vue components.
I've successfully used this approach in a Nuxt app where multiple components needed to some data from an API but I didn't want to implement my own caching mechanism in Vuex for keeping track of which IDs are already present or being fetched.
I'm sure it doesn't cover every conceivable usecase, but it did the trick for me.
A more realistic Vue template that handles the loading and error states might look something like: