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

332
Vistas
waiting for an api call back to finish before calling another api in vuex

I have this action in vuex which basically calls two APIs. modifyResults has a call back function and I want to wait for this callback to finish then execute the updateResults. This is my setup:

//vuex

import {modifyResults, updateResults} from './api';
const actions = {
  async modifyResults({ dispatch }) {
    try {
      // waiting for ModifyResults to finish entirely but after
      // functionOne from api folder is finished
      // it executes updateResults from here and then executes
      // functionTwo from api folder
      await modifyResults();
      dispatch('updateResults');
    } catch (error) {
      // catch errors
    } finally {
      // loading variable set to false
    }
  },
  async updateResults({ dispatch }, ) {
    try {
      const { sources } = await updateResults();
      dispatch('setItems', sources);
    } 
    //blah blah
  },
}

// api.js

export const modifyResults = async () => {
  await functionOne({someApi},
    async functionTwo(status, resposne) => {
      const { data } = await api.post(//blah blah);
      return data
    }
  )
},
export const updateResults = async () => {
  // blah return result
},

So basically what happens is this is the order in which these functions are executed:

1- functionOne
2- updateResults
3- functionTwo

whereas I want this order:

1- functionOne
2- functionTwo
3- updateResults
about 4 years ago · Juan Pablo Isaza
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