使用ionic3的本机存储时出现错误。它无法正确读取本机存储中的数据。错误代码:2,但没有详细描述。
public async getToken(): Promise<AccessToken> {
let token = null;
let expires = null;
try{
token = await this.storage.getItem(this.ACCESSTOKEN_KEY);
expires = await this.storage.getItem(this.ACCESSTOKEN_EXPIRES_KEY);
}catch(e){
alert(JSON.stringify(e));
}
if (token == null || expires == null || expires < new Date()) {
token = null;
}
return token;
}
Run Code Online (Sandbox Code Playgroud)
小智 5
错误代码包含一个整数,用于指定发生的错误: