ionic3 - Ionic 3 native-storage error code : 2, 无详细描述

标签 ionic3

我在使用 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;
  }

错误截图:

enter image description here

最佳答案

错误代码包含一个整数,指定发生的错误:

  • 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/

相关文章:

ionic-framework - Ionic 3 Cordova 文件插件为 copyFile 操作提供错误

angular - 我如何跟踪 ionic 2 中 app.component.ts 中的每个错误

sqlite - 无法获取行项目只能获取行数 ionic 3 sqlite

javascript - ionic 框架 typescript : Callback function is not able to access `this` variables

cordova - 为什么在 android 8 上尝试保存联系人时 ionic-native/contacts 插件会导致应用程序崩溃?

javascript - 尝试关闭 Ionic Loader 时出错

html - ionic 3 中的 touchstart 和 touchend 事件

AngularFireList 不可分配给类型 'Observable<Response>

javascript - 如何在一个请求中上传多个文件?

angular - 将 Ionic 存储项作为字符串获取