dimanche 18 février 2018

How do I access returned objects using Ember Data?

I have an Ember component that uses Ember Data. I'm just trying to get some data and simply console out one of the values I get back.

The JSON object being returned looks like this:

{
    success: true,
    sets: [
        {
            name: 'Some Name'
        },
        {
            name: 'Some Different Name'
        }
    ]
}

This is what my route looks like:

export default Ember.Route.extend({
    model() {
        this.get('store').findAll('set').then(function(data) {

            data.forEach(function(set, index) {
                console.log(set.name);
            });

            return data;
        });
    }
});

Instead of seeing Some Name and Some Different Name I see some kind of Ember objects:

{
    _dependentKeys: undefined
    _getter: function get()
    _meta: Object { type: "string", isAttribute: true, name: "name" }
    _readOnly: false
    _setter: function set()
    _suspended: undefined
    _volatile: false
    isDescriptor: true
}

How do I access the actual values of my objects?




Aucun commentaire:

Enregistrer un commentaire