Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!