question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Pagination metadata to JSONAPISerializer

See original GitHub issue

Is it possible to support returning metadata with a route’s response? (Would be good for something like pagination).

Ie a JSON API response like:

{
  data: [
    { type: 'item', id: 1 },
    { type: 'item', id: 2 },
    { type: 'item', id: 3 },
    { type: 'item', id: 4 },
    { type: 'item', id: 5 }
  ],
  meta: {
    total: 200
  }
}

Where this is eventually available in the controller like so:

this.get('model.meta');

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
samselikoffcommented, Feb 6, 2016

If you want you can manually call serialize then add the data yourself in the route handler:

this.get('posts', ({post}, request) => {
  let json = this.serializerOrRegistry.serialize(post.all());

  json.meta = {};
  return json;
});

Would that work for now?

1reaction
denzocommented, Feb 6, 2017

Is any updates/examples on this (pagination)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Pagination metadata to JSONAPISerializer #442 - GitHub
Is it possible to support returning metadata with a route's response? (Would be good for something like pagination).
Read more >
Pagination in Ember with a JSON API Backend
Every Ember Data model has a property called meta where arbitrary metadata can be stored. First approach: Make the backend return links in...
Read more >
How to use json-api pagination links in Ember 2.x?
You just have to create a Serializer that intercepts the payload from the server and moves the response.links into Ember Data's metadata.
Read more >
JSON:API — Latest Specification (v1.1)
Any pagination links in a relationship object MUST paginate the relationship data, not the related resources. Note: See fields and member names ...
Read more >
Adding Pagination to an API - MetaBates.com
Here the API returns the pagination meta-data right inside of the JSON response. The advantage here is that everything is very visible to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found