我正在使用ember-simple-auth和jwt来验证用户配置文件,这是用于注册的代码,注册后我将不打印在控制台中创建的令牌值(在响应中)< / p>
import Controller from '@ember/controller';
export default Controller.extend({
actions: {
signup: function(){
var credentials = this.getProperties('name','identification','password');
let list = this.store.createRecord('user', {
name: credentials.name,
email: credentials.identification,
password: credentials.password
});
list.save();
// I want to print the token value in console here
this.setProperties({
'name': '',
'identification': '',
'password': ''
});
}
}
});
答案 0 :(得分:1)
@Sreenath,因为您说过jwt存储在服务中, 这就是console.log的方式。
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default Controller.extend({
nameOfService: service(),
actions: {
signup: function(){
// ...
// I want to print the token value in console here
console.log(this.nameOfService.nameofPropertyThatJWTIsOn);
// ...
}
}
});