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

193
Vistas
vue data variables are undefined in method

I'm working with Vue and making a game and when getting the data for said game, some variables that I have defined in data are being returned undefined. Here's the code:

data() {
    return {
      receivedGame: undefined,
      allSteps: [],
}
methods: {

     async gameData() {
     const response = await fetch(`...`);

        const responseData = await response.json();

        this.receivedGame = responseData.steps; //returns correct data

        responseData.steps.map((step) => {
          this.allSteps.push({ //returns error, allSteps is undefined
            type: step.type,
          });
        });
 }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The data hook must be a function that returns an object. Here you don't return anything!

data() {
  return {
    receivedGame: undefined,
    allSteps: [],
  }
}

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