jeudi 5 novembre 2015

Ember data DS.JSONAPIAdapter pagination

I am working on a project using EmberJS 2.1 and EmberData 2.1.

Everything is good but seems I am not able to understand how can I paginate results from the API.

Current response that I get from the API:

{
  "data": [
    {
      "type": "user",
      "attributes": {
        "firstName": "John",
        "lastName": "Doe",
        "company": "Google",
        "id": "1",
        "title": "Mr.",
        "email": "john@doe.com"
      },
      "id": "1"
    },
    {
      "type": "user",
      "attributes": {
        "firstName": "John",
        "lastName": "Doe",
        "company": "Google",
        "id": "2",
        "title": "Mr.",
        "email": "john@doe.com"
      },
      "id": "2"
    },
    {
      "type": "user",
      "attributes": {
        "firstName": "John",
        "lastName": "Doe",
        "company": "Google",
        "id": "3",
        "title": "Mr.",
        "email": "john@doe.com"
      },
      "id": "3"
    },
    {
      "type": "user",
      "attributes": {
        "firstName": "John",
        "lastName": "Doe",
        "company": "Google",
        "id": "4",
        "title": "Mr.",
        "email": "john@doe.com"
      },
      "id": "4"
    }
  ]
}

and my route looks like this:

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
    model: function(){
        return this.store.findAll('user');
    }
});

Is there any resource where I can learn how to implement pagination? I've found a lot of tutorials, but they're for DS.RESTAdapter.

Thank you




Aucun commentaire:

Enregistrer un commentaire