let mindex = 0 ;
let sum = this.multipleSelection.length ;
let successNum = 0 ;
for(const item of this.multipleSelection){
jokeNumPP
axios
.get(MODULE_PATH.GAL_PATH + "/init-rule/init",{
params:{
admCode:item.admCode,
eleCode:item.eleCode,
fiscal:this.fiscal
}
})
.then(({ data,code }) => {
flag = true
if(code=="200"){
successNumPP
console.log(successNum) //
}else{
failNumPP;
console.log(failNum)
}
})
.catch((err) => {
this.$message({
type: "error",
message: err.msg
});
});
}
console.log(jokeNum)
console.log(flag)
console.log(this.successNum) //
The code, as above, makes a request in a for loop, and then saves the eligible data to a new variable according to the returned data, but at present, after the end of the for loop, the new variable is printed first, and the new variable is still empty. In the for loop condition judgment, it is the last print, asking for advice on how to get the correct new variable after the end of the loop?