Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Calling function shortly after page load, once results are received from controller

I'm trying to call a computed property (which relies on a data variable to be set from incoming json) upon page creation but it says that it can't read the data for 'undefined'. This is due to the data I need not being fully loaded, I'm pretty sure. When I set it to run 2 seconds after created(), it works just fine.

How can I neatly set this to only run the function on my data variable one time but ONLY once the data results are actually set?

<div id="app">
  <div v-for="(value, employee) in employeeFunction" :key="employee">
    @{{value}}
  </div>
</div>


<script>

var vm = 
new Vue({
  el: "#app",

  data: {

    results: [
        {//data is in here

        }
    ],

  },
  created: function(){
    this.interval = setInterval(() => this.employeeFunction(), 2000);
  },
  computed: {

    employeeFunction() {
      console.log('employee data')
      employeeResults = this.results
      console.log(employeeResults)
      return employeeResults
    },

    
  }
});
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Instead of using the created() lifecycle-hook try with mounted()

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda