[Vuejs]-Is there a smart possibility to get API results without sending requests every second? [VueJS | Vuetify]

1👍

Yes you can by firing an event. for example:

in your app.js

window.Fire = new Vue();

For example here you create a user then you want to update table after creating a new user, Follow these steps:

createUser(){

 // FireUpdate is your fire name, you can give it any name you want!
 // Call this after you post something to specific route.

 Fire.$emit('FireUpadte'); 
}

Then you will load new users using this approach:

created(){
  // Load new Users after created.

  Fire.$on('FireUpadte', () => { this.createUser(); });
}

For more information check this video: https://www.youtube.com/watch?v=DHuTkJzH2jI&list=PLB4AdipoHpxaHDLIaMdtro1eXnQtl_UvE&index=20

0👍

What you’re looking for are websockets. You establish a websocket connection and it stays open, allowing the server to notify the web app when something changes.

You can run your own socket.io server on a Node.js backend or use a service like Pusher.com (very cheap, free tier is pretty big).

I highly recommend going the Pusher.com route, they also have great tutorials ; )

https://pusher.com

Leave a comment