samedi 16 décembre 2017

ember map object from ember data store

I am trying to map an object in the model hook. I have this object provided by mirage.

let temp = {"users": [
    {
        "id":1,
        "forename":"Test",
        "surname":"Name"
    },
    {
        "id":2,
        "forename":"Hans",
        "surname":"Solo"
    },
    {
        "id":3,
        "forename":"Peter",
        "surname":"Pan"
    }
]

};

In the model hook I want to use this:

return this.get('store').findAll('user').then(x => x.map(x => x.id + x.forename + x.surname));

I am getting this:

1[object Object][object Object] 2[object Object][object Object] 133000[object Object][object Object] 3[object Object][object Object]

And I am using this in the template (at the moment just for test if it works):





I tried to just map to the ID and this works fine. Furthermore it works fine if I will declare the temp directly in the model hook. Is there anything with promise which impede my map?

I need this working because I am implementing a ember power select multiselection and I want to show the user the id, forename and surename.




Aucun commentaire:

Enregistrer un commentaire