What's the best way to decorate an existing model in ember.js with additional data from an external API?


#1

Hi,

I have a movie model with a year and a title stored in a local storage. There is a list view and a details view. In the list view you can enter new movies, edit and delete them and see all movies listed with their year and title. For the details view (new route) there should be additional data fetched (read only) from an external API for each movie. In order to get that data you have to make 3 different requests to that API. The first one is to get the specific movie id of the external API by year and title. The second one is to get the additional movie details by that api movie id like genre and so on. The third one is to get the cast of that movie.

What’s the best way to handle that? Serializer, Adapter?

I’m new to ember.js and hopefully someone can point me to the right direction.

Thank you


#2

@fllipmoe See the RSVP package docs for using an array of promises https://github.com/tildeio/rsvp.js/blob/master/README.md#arrays-of-promises Perhaps you could use the afterModel method in your route to fetch the additional data see http://emberjs.com/api/classes/Ember.Route.html#method_afterModel