Getting attributes from Internal Models

Hi, when i get response and serialize it to jsonapi i have bad-looking response. I’m talking about long path to attributes. Before using ember-data i just created objects with computed property to get attribute which i need, now if i want to get ‘name’ i have to write something like ‘content._data.properties.name’ what looks bad in hbs files. Should i use helpers to it or is there any posibility to get this attribute if i know this long path to them?

Thanks for help!

You should not have to do content._data.properties.name at all.

If you’re using an API that conforms to the jsonapi spec, ember-data should automatically load your models for you.

This means you should be able to do something like this:

store.findRecord('user', 1).then(user => {
    // user is an ember-data record
    console.log(user.get('name')); // outputs the user's name
});

If your server doesn’t return or expect correct json, you’ll want to fix that in your adapters and/or serializers.