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

164
Vistas
Loaded fields are not initialized in the additional function

I use two functions to load some components for my page and save it in two fields representatives and allUsers. Then I try to use additional func subtractSets() to a little bit modify loaded data. My problem is that fields this.representatives and this.allUsers in this adittional function are still not initialized. What I can do to get loaded data in subtractSets()?

setup() {
     const representatives = ref([])
     const allUsers = ref([])
 data() {
   return { 
     representatives,
     users
   }
 }
},

methods(): {
   loadUsersRepresentatives() {
       axios.get('getRepresentatives').then(res => {
            this.representatives = res.data
        }).catch(() => {
            ...
            })
        });
     },
     loadAllUsers() {
         axios.get('/getAllUsers').then(res => {
         this.allUsers = res.data
         }).catch(() => {
             ...
             })
         });
    },
    subtractSets(obj1, obj2) {
            ...
    },
    showRepresentativesDialog(facultyID) {
          this.loadUsersRepresentatives(facultyID)
          this.loadAllUsers()
          this.subtractSets(this.representatives, this.allUsers)
          this.representativesDialog = true
      }
},
´´´
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are missing async / await

methods(): {
   async loadUsersRepresentatives() {
       return axios.get('getRepresentatives').then(res => {
            this.representatives = res.data
        }).catch(() => {
            ...
            })
        });
     },
     async loadAllUsers() {
         return axios.get('/getAllUsers').then(res => {
           this.allUsers = res.data
         }).catch(() => {
             ...
             })
         });
    },
    subtractSets(obj1, obj2) {
            ...
    },
    async showRepresentativesDialog(facultyID) {
          await this.loadUsersRepresentatives(facultyID)
          await this.loadAllUsers()
          this.subtractSets(this.representatives, this.allUsers)
          this.representativesDialog = true
      }
},
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