Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ember js get meta informations from json

i have a json data from my server:

{
  "post": {
    "id": 1,
    "title": "Progressive Enhancement is Dead",
    "comments": ["1", "2"],
    "links": {
      "user": "/people/tomdale"
    }
  },

  "meta": {
    "total": 100
  }
}

look exactly like the documentation (https://guides.emberjs.com/v2.5.0/models/handling-metadata/) i try to get the meta object with no success

export default Ember.Route.extend({
  model() {
    var data = this.store.findAll('post');
    data.then((result) => {
      let meta = result.get('meta');
      console.log(meta); //this return me undefined
    })
    return data;
  }
});
like image 566
Michael Avatar asked Jun 05 '16 18:06

Michael


1 Answers

You are using findAll method and it does not support meta data. You should use this.store.query('post', {/*params*/}) method instead, if you want to get multiple posts with meta data.

like image 81
Igor Avatar answered Oct 03 '22 15:10

Igor