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)