Using Element UI's $confirm in vue, how to execute an asynchronous method after its .then () method.

as shown below, call the api in the background to delete when you click the confirm button for deletion.

clipboard.png

confirmDelete(){
    let self=this;
    let idarr=self.mulId;
    let params={
        "profileId":idarr
    };
    return new Promise((resolve,reject)=>{
        api.deleteProFile(params).then(res=>{
            if(res.errMsg=="Success"){
                console.log("");
            }
            resolve(res.errMsg);
        })
   })    
},
async deleteProfiles(){
    let self=this;
    let data=self.mulSection;
    let flag=false;
    let msg=", ?";
    data.forEach(item=>{
        self.mulId.push(item.id);
    })
    this.$confirm(msg, "", {
        confirmButtonText: "",
        cancelButtonText: "",
        type: "warning"
        }).then(() => {
            let msgRet=await self.confirmDelete();
            if(msgRet=="Success"){
                self.notify("","success",1000);
            }
            else{
                self.notify("","warning",1000);
            }
        }).catch(() => {
            console.log("cancel");
    });
},

but every time you click the OK button, you go to the catch section. Then the content in .then () is not executed either. At present, I want to execute the delete method of calling background api in this .then () method.

Oct.20,2021

landlord, hello ~
there are some problems in the code. Try the following:

.then(async () => { //   async
            let msgRet= await self.confirmDelete();
            if(msgRet=="Success"){
                self.notify("","success",1000);
            }
            else{
                self.notify("","warning",1000);
            }
        })
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaba95-47e47.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaba95-47e47.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?