Stories

Detail Return Return

async await實際用法 - Stories Detail

async handleSubmit() {
      await this.handleSubmitReport()  // 1
      await this.handleSubmitEdit()    // 2
      this.showSuccess = true          // 3
      this.showSuccessText = '你已成功提交檢查結果!'
    },

// 執行接口1
async handleSubmitReport() {

  const { data } = await postAction(this.api.report, this.params.hiddenList)
  if (data.success) {
    return data.result
  } else {
    this.$message.error(data.message)
    this.$tip.loaded()
    return null
  }
},

// 執行接口2
async handleSubmitEdit() {
  const { data } = await postAction(this.api.edit, this.dataInfo)
  if (data.success) {
    return data.result
  } else {
    this.$message.error(data.message)
    this.$tip.loaded()
    return null
  }
},
user avatar simonbaker_5ec61c266b1df Avatar sean_5efd514dcd979 Avatar ssbunny Avatar mstech Avatar webinfoq Avatar chenqiwen Avatar mochou_5b3c64f18b5f1 Avatar
Favorites 7 users favorite the story!
Favorites

Add a new Comments

Some HTML is okay.