I'm currently using Vue Router's beforeEnter hooks to retrieve data for one of my routes.
{
path: '/A',
beforeEnter: (to, from, next) => {
loadData();
next();
},
}
A simple example of the flow would be:
Navigate to Route A --> Loading Data
Navigate to Route B
Navigate to Route A --> Loading Data again
How can i prevent the second & obsolete API Call? since it's not important that the data is that up-to-date.
I could do: if (!dataIsAlreadyThere) loadData(), but this is somehow not nice to have with many routes. Are there any other solutions or ideas out there?
loadDatainstead? For example, all the data fetching routines go through the same place that acts as a (or interacts with) Cache Manager.