DEV Community

Discussion on: Quick Vue Tip: Cleaner Data Fetching

Collapse
 
therealdanvega profile image
Dan Vega • Edited

Great tip Miguel. You can also use this to watch the route or route params if your avenger id was coming from the route (/avengers/3). You just need to put it in quotes like this:

watch: {
  '$route.params.id': {
    immediate: true,
    ...
  }
}
Collapse
 
imtiyaz profile image
Mohammed Imtiyaz

Great Tip!!

Thanks for sharing it. Just like you read my mind.

Collapse
 
julianalmandos profile image
Julian Luis Almandos

Thanks for sharing this Dan, sometimes var manipulation can be very tricky

Collapse
 
mccabiles profile image
Miguel

Yes! Applying this to your Vue routes is the logical extension for this pattern, and is how I use it in my apps as well. Thank you for sharing, Dan!