我在使用 Ionic3 的原生存储时出错。它无法正确读取 native 存储中的数据。错误码: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;
}
错误截图:
最佳答案
错误代码包含一个整数,指定发生的错误:
- NATIVE_WRITE_FAILED = 1
- ITEM_NOT_FOUND = 2
- NULL_REFERENCE = 3
- UNDEFINED_TYPE = 4
- JSON_ERROR = 5
- WRONG_PARAMETER = 6
关于ionic3 - Ionic 3 native-storage error code : 2, 无详细描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48534417/