You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing a services based architecture for a website where the same service is called from different parts of the app different times, so I need some kind of abstraction to make it scalable.
My first approach was to move the services I already had into composables in order to be able to auto-import them. This seem to be working for non-nested pages. But in the case of nested dynamic pages, this doesn't seem to work (to be more precise, it works when loading the page, but not when browsing from another page through a nuxt-link).
I've seen this issue where it doesn't recommend to use async useFetch in composables (I'm using plain async $fetch) Here is a minimal reproduction of my architecture where I basically use a loadBeer function that simply calls a fetchBeer one that does the API call (could not make it work due to stackblitz not passing routes correctly)
My question is what would be the recommended best approach for having a services architecture like this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm developing a services based architecture for a website where the same service is called from different parts of the app different times, so I need some kind of abstraction to make it scalable.
My first approach was to move the services I already had into composables in order to be able to auto-import them. This seem to be working for non-nested pages. But in the case of nested dynamic pages, this doesn't seem to work (to be more precise, it works when loading the page, but not when browsing from another page through a nuxt-link).
I've seen this issue where it doesn't recommend to use
async useFetch
in composables (I'm using plainasync $fetch
) Here is a minimal reproduction of my architecture where I basically use aloadBeer
function that simply calls afetchBeer
one that does the API call (could not make it work due to stackblitz not passing routes correctly)My question is what would be the recommended best approach for having a services architecture like this?
Beta Was this translation helpful? Give feedback.
All reactions