Tag Archives: Cannot read property ‘data’ of undefined error

Cannot read property ‘data’ of undefined;at api showModal success callback function

error code:


wx.showModal({
        title: 'prompt',
        content: 'OK to add?',
        success(res){
          if (res.confirm) {
            //Add each other as your friend
            db.collection('users').doc(app.userInfo._id).update({
              data:{
                friendList:this.data.messageId
              },
            }).then((res)=>{});
          }else{}
        }
      })
              

View Code:

will success spelled it is ok to change

success: (res)=> {

}