Async/await doesn't work after multi-level calls?


<button open-type="getUserInfo" @getuserinfo="bindGetUserInfo"></button>

export default {
  methods: {
    bindGetUserInfo(e) {
       //  
       this.submitForm()
    },
    submitForm() {
       // 
       this.login()
    },
     async login () {
      wx.login({
        success:async res => {
          let code = res.code;
          if (code) {
            this.submitData["code"] = code

            const data = await Api.Login(this.submitData);  //ajax
            if (data.errcode === 0) {
            //
            }
The ajax request in the

code is defined in the login method. The order of clicking the button call is bindGetUserInfo-> submitForm-> login,await without waiting. I replaced it with

.
export default {
  methods: {
    async bindGetUserInfo(e) {
       //  
       await this.submitForm()
    },
    async submitForm() {
       // 
       await this.login()
    },
     async login () {
      wx.login({
        success:async res => {
          let code = res.code;
          if (code) {
            this.submitData["code"] = code

            const data = await Api.Login(this.submitData);  //ajax
            if (data.errcode === 0) {
            //
            }

this doesn"t work either. I don"t know why?

Jul.01,2021
The method after

await needs to return a promise. Make sure there is no problem with this. Here the login method does not return promise.


   async login () {
    await new Promise((resolve, reject) => {
      wx.login({
        success: res => {
          resolve(res)
        },
        error: err => {
          reject(err)
        }
      })
    })
  }
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-1b3accf-2c223.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-1b3accf-2c223.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?