Q:

call method every so often vue js

I need to call a function every so often, what I want is to update the data every so often for this reason I need to call that method, I'm using vue js.
in the same way I want to know in which property of vue js locate it, thanks, I will investigate all the comments
I need to call the 'listar()' method every 30 seconds
<script>
  export default {
    methods: {

            listar(){
            let me=this;
                me.mesas=[];
                axios.get('api/mesas/ListarTodos').then(function(response){
                    //console.log(response);
                    me.mesas=response.data;
                      me.loading=false;
                }).catch(function(error){
                    console.log(error);
                });

        },
}
</script>

This did not work for me
setTimeout(() => {
         //
}, 300)

Upgrade 1
this code actually works for me,but the problem is — it will keep running after you switch to another page, because it’s a single page application.
I'm using clearInterval () but it does not work, the method keeps running even though I change the page (component).
Clear the clear only the first time I enter another page, then no longer
Ref-->https://renatello.com/vue-js-polling-using-setinterval/
<script>
import axios from 'axios'
  export default {

data () {
      return {
        polling: null,

       },
methods: {

        listar(){
                let me=this;
                    me.mesas=[];
                    axios.get('api/mesas/ListarTodos').then(function(response){
                        //console.log(response);
                        me.mesas=response.data;
                          me.loading=false;
                    }).catch(function(error){
                        console.log(error);
                    });

     pollData () {
      this.polling = setInterval(() => {

         this.listar();
       }, 3000) },

                },

 created () {
      this.pollData()

    },

 beforeDestroy () {
         clearInterval(this.polling)
    },
  }
</script>

A:

Like ittus said, you should use setInterval:
setInterval(() => {
    // call listen()
}, 30 * 1000);

setInterval returns an object you can pass to clearInterval in order to stop calling listen.
However, if you want to take into account the time of the request, you could also use setTimeout in a .finally block at the end of your (promise) request:
axios.get('api/mesas/ListarTodos').then(function(response){
    //console.log(response);
    me.mesas=response.data;
    me.loading=false;
}).catch(function(error){
    console.log(error);
}).finally(function(){
    setTimeout(/*call listen in a function*/, 30 * 1000);
});

Anyway, it doesn't have much to do with vuejs

