Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 3 native-storage error code : 2, no detailed description

Tags:

ionic3

I had an error when I used Ionic3's native-storage. It couldn't read the data in native-storage correctly. The error code: 2, but there was no detailed description.

  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;
  }

Error screenshot:

enter image description here

like image 345
Gerson Avatar asked Dec 05 '25 14:12

Gerson


1 Answers

Error codes contains an integer which specifies the occurred error:

  • NATIVE_WRITE_FAILED = 1
  • ITEM_NOT_FOUND = 2
  • NULL_REFERENCE = 3
  • UNDEFINED_TYPE = 4
  • JSON_ERROR = 5
  • WRONG_PARAMETER = 6
like image 172
Deyan Vatsov Avatar answered Dec 08 '25 07:12

Deyan Vatsov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!