We call an API from login page, and then transition to page called 2fa. On transition we call an api which send 2fa code after sucessfull login. and then redirect to 2fa page.
on login action
is2FASave.save().then((response) => {
if(response.data.is2fa){
this.get('session').setLoginCredential(email,password);
var sendCode = this.store.createRecord('sendCode', {
email: email,
password: password
});
sendCode.save().then((res) => {
this.get('store').unloadAll('sendCode');
this.transitionToRoute('twofa')
},(error)=>{
});
}
}
On twofa page we have resend button on its click where we call same api which is written on twofa controller
actions: {
/**
* Resend 2FA code.
*/
twoFaResend: function() {
var email = this.get('session').getEmail(),
password = this.get('session').getPassword();
var sendCode = this.store.createRecord('sendCode', {
email: email,
password: password
});
sendCode.save().then((res) => {
},(error)=>{
});
},
while we call this api on twofa page it gives error
Assertion Failed: You can only unload a record which is not inFlight.
<send-code:null>
"
The error is shown as after the resend code button is clicked
When we check ember data it has value of previous api call.
Now we also tried calling the same api multiple times on same page which works absolutely fine. Dis issue occurs when it is transitioned to other page and api is called on another page.
Aucun commentaire:
Enregistrer un commentaire