HATEOAS with Ember Data

This post was originally published on thoughtbot’s blog.

Ember Data introduced strong conventions around how to structure API responses. While these conventions allow us to move quickly, there are additional steps we can take to minimize the coupling between the front end and back end. Using concepts from HATEOAS (Hypermedia as the Engine of Application State) we can make our Ember applications more flexible and resilient to changes on the server.

Ember Data

Ember Data can take advantage of API responses containing a links key pointing to URLs to associated resources. Ember Data will automatically pick up on those links as the source of the association’s data instead of using the default URL structure. In a use case where we want to asynchronously fetch associated resources, our API has more flexibility around URL structure.

Let’s say we have a Repo resource that has many Commits and we want the commits to be loaded asynchronously in Ember. How would we set up our API endpoints?

read more…