[Vuejs]-Vue : How to use async await accordingly in a function array of which can have two functions for Promise.all?

0๐Ÿ‘

โœ…

To use await in those callbacks, each callback function itself needs to be async:

export default {
  methods: {
    submitToTheOthers(){
      โ‹ฎ
      return this.idxs.map( (_entry, i) => {
        return updateGeneralInfoToOther(1, data, this.serverFullAddress[i]).then(async (res) => { // [here2]
            โœ…                                                                     ๐Ÿ‘†
          await someAsyncMethod()

          if (res.status == 200) {
            โ‹ฎ
            if (logoData.logo) {
              this.sendFileToOther(/*...*/).then(async (res) => { // [here]
                  โœ…                               ๐Ÿ‘†
                await someAsyncMethod()
              })
            }
            if (logoData.logo1) {
              this.sendFileToOther(/*...*/).then(async (res) => { // [here]
                  โœ…                               ๐Ÿ‘†
                await someAsyncMethod()
              })
            }
          }
        })
      })
    },
  },
}

Leave a comment