I have the following code in ember 2.6; ember-data 2.6.1
import Ember from 'ember';
export default Ember.Route.extend({
activate() {
var route = this;
var sessionId = localStorage.getItem('sessionId');
if (sessionId) {
localStorage.removeItem('sessionId');
this.store.findRecord('session', sessionId).then(function found(session) {
session.destroyRecord();
route.transitionTo('index');
});
} else {
this.transitionTo('sessions.new');
}
}
});
I have a logout button that has hbs template code as:
<li> Logout</li>
The Route.extend
code is executed when /sessions/delete is called!
What I observe is the order of REST calls are:
1) ***DELETE*** http://ift.tt/2a0l9Wz;
2) ***GET*** http://ift.tt/2a0l9Wz;
The second REST request throws and error because by that time the session/cookie is already cleaned up.
What I expect is the order of the REST calls should actually be reverse but I am unable to figure out why is it not like that!
Any pointers & hints will be appreciated ;)
Aucun commentaire:
Enregistrer un commentaire