0👍
Yeah it should work automatically.
Except one thing missing: in order to use the response, you should/could await
or then
the value fetched.
I understand it will return the fetched data for the first time. Afterwards it will consistently return the cached data for that requested URL.
How it works
By using axios interceptors instead of adapters, each request is
passed through the interceptor before calling the adapter and before
returning to the original caller. Adapters are the final step and they
are responsible for the actual network call, so, by choosing to use
interceptors, we create a minimally invasive approach that allows you
to still use the axios adapter of your choice.Before the request is delivered to the adapter, our request
interceptor checks if the request have already been cached and if it’s
a valid one, checks if the request should be cached (sometimes you
don’t want cache at all, and it’s ok), if there’s already a request
sent to the network that we can wait for it and many more other
checks.After the adapter gets the response, we check if it belongs to a
cacheable request, saves it into the storage, resolves other requests
awaiting for the same resource and finally returns the response to the
original caller.
- [Vuejs]-How to set image src with alias in Vue3 + Vite
- [Vuejs]-How to integrate the mavon editor with nuxt3?