The problem of vue fetching multiple data and merging

I"m distributing two fetch functions to get data in different places
and now I want to merge the two result data and put them into one table
, that is, is it possible for two action functions to finish mutation, together?
how do I write it

?
const actions = {

      getLatestJob(context){
         const result=api.getJobJson(context);
         result.then(function (res) {
        console.log("----------------------JSON QUERY NBU JOB:  res.status:"+res.status);
      if(res.status === 200){
        return res.json()
      }
    }).then(function (json) {

      console.log(typeof Array.from(json), Array.from(json));
      context.commit("setJson", json);
    })

      },

      getLatestJobFromShield(context){
         const result=api.getJobJsonFromShield(context);
         result.then(function (res) {
        console.log("----------------------JSON QUERY Shield JOB:  res.status:"+res.status);
      if(res.status === 200){
        return res.json()
      }
    }).then(function (json) {

      console.log(typeof Array.from(json), Array.from(json));
      //context.commit("setJson", json);
    })
      }

};

//mutation  
const mutations = {

    setJson(state,db){

then vue

 getJson(){

                this.$store.dispatch("getLatestJob");
                this.$store.dispatch("getLatestJobFromShield");

            },

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

The results calculated by the

methods are passed into a function in vuex, and the results can be calculated according to the two passing parameters in the function


solution 1: use Promise.all () , After waiting for both asynchronies to return results, merge
scenario 2: use async await < / A > Syntax Sugar performs asynchronous operations sequentially

Menu