funkensturm / ember-local-storage

The addon provides a storageFor computed property that returns a proxy and persists the changes to localStorage or sessionStorage. It ships with an ember-data adapter.
https://www.funkensturm.com/ember-local-storage/
MIT License
218 stars 76 forks source link

this.get('storage').reset is not a function #321

Closed wojtasss closed 2 years ago

wojtasss commented 4 years ago

set and get values from storagefor('storage') works without problem, but when I try use reset() or clear() then error occurs.

"ember-local-storage": "^1.7.2",

import StorageObject from 'ember-local-storage/local/object';

export default class Storage extends StorageObject {
  initialState() {
    return {
      access_token: ''
    }
  }
}
import Base from 'ember-simple-auth/authenticators/base';
import fetch from 'fetch';
import { storageFor } from 'ember-local-storage';

export default class JwtAuthenticator extends Base {
  serverTokenEndpoint = '/api/v1/auth'
  storage = storageFor('auth')
  ...
  this.get('storage').reset() // <-- here error occurs, reset is not a function in browser console
  ...
}
fsmanuel commented 4 years ago

@wojtasss sorry for the late reaction. Can you tell me which ember version you are using?

fsmanuel commented 4 years ago

@wojtasss this should work:

import Base from 'ember-simple-auth/authenticators/base';
import fetch from 'fetch';
import { storageFor } from 'ember-local-storage';

export default class JwtAuthenticator extends Base {
  serverTokenEndpoint = '/api/v1/auth'
  @storageFor('auth') storage
  ...
  this.get('storage').reset() // <-- here error occurs, reset is not a function in browser console
  ...
}
fsmanuel commented 2 years ago

@wojtasss I'm closing the issue. If it's still a problem please reopen!