咸虾米
咸虾米
  • 发布:2025-09-30 12:20
  • 更新:8 分钟前
  • 阅读:16

云对象预处理_before内如何抛出uni-id-check-token-failed触发客户端跳转登陆页面

分类:uniCloud
let userInfo;  
_before: async function () {  
    const clientInfo = this.getClientInfo();  
    const token = this.getUniIdToken();   
    this.uniID = uniID.createInstance({  
        clientInfo  
    });  
    userInfo = token ? await this.uniID.checkToken(token) : {};   
    throw new Error(  
        JSON.stringify({  
            errCode: userInfo.errCode,  
            errMsg: userInfo.errMsg  
        })  
    );  
}

按照文档说明:checkToken接口可能返回uni-id-token-expireduni-id-check-token-failed错误码,二者均会触发客户端跳转登陆页面。

如果在云对象内的方法return {errCode,errMsg}在客户端是可以触发登录页面的,但是在_before中throw会字符串原样输出,不会触发登录,请问怎么解决那?

2025-09-30 12:20 负责人:无 分享
已邀请:
DCloud_uniCloud_CRL

DCloud_uniCloud_CRL

在_after中可以拦截error后再return

要回复问题请先登录注册