我们从登录页面调用API,然后转换到名为2fa的页面。在转换时,我们称之为api,在成功登录后发送2fa代码。然后重定向到2fa页面。
登录操作
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)=>{
});
}
}
在twofa页面上,我们在其点击的地方重新发送按钮,我们称之为相同的api 这是在twofa控制器上写的
行动:{
/**
* 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)=>{
});
},
虽然我们在twofa页面上将此api称为错误
断言失败:您只能卸载不在飞行中的记录。
<send-code:null>
“
现在我们也尝试在同一页面上多次调用相同的api,这绝对没问题。当它转换到其他页面并且在另一页面上调用api时会发生Dis问题。