i’m working on pulling in the currentUser’s info to display in template.hbs. i’m not sure where i’ve gone wrong. each user can log in, but I’m not able to access that data to display it. CurrentUser data is showing up in Network tab in Chrome, but when I look in ember tab and then inside data models it doesn’t show any data being pulled in.
Application/adapter.js
import DS from 'ember-data';
import config from '../config/environment';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
authorizer: 'authorizer:token',
host: config.DS.host,
namespace: config.DS.namespace,
});
Application/controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
wizard: Ember.inject.service('wizard'),
currentUser: Ember.inject.service(),
queryParams: ['cat'],
cat: null,
});
Application/route.js
import Ember from 'ember';
import Mixin from 'ember-simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(Mixin, {
currentUser: Ember.inject.service(),
beforeModel() {
return this.get('currentUser').loadCurrentUser();
}
});
Services/current-user.js
import Service from '@ember/service';
export default Service.extend({
store: Ember.inject.service(),
session: Ember.inject.service(),
pids: null,
loadCurrentUser() {
if (this.get('session.isAuthenticated')) {
return this.get('store').queryRecord('pids', { current: true })
.then((pids) => {
this.set('pids', pids);
});
}
}
});
template.hbs
<div class="hello" style="color: white;"> <h1>{{log currentUser.pids.firstname }}, You Are Officially Logged In!!</h1></div>
It’s logging an undefined value.