0
votes

I have a need to request some data from a third party API endpoint in an Ember app (Using Ember 1.7)

I'm not sure the best way to handle the response, should I:

  • Use $.ajax in my model hook, return the raw data and not worry about Ember models?

  • Use $.ajax in my model hook, use store.createRecord to map the returned data into models and use store.all to return this data to my component.

  • Use an adapter and use store.findAll to get the data (could be tricky as the returned data won't match my models).

I'm not quite sure of the pros and con's of getting data in this way, any input would be great.

1

1 Answers

0
votes

You should go with the second option but instead of creating the record, it's better for you to push payload into the store. It's better because after pushing into the store, you won't get your model dirty, it would have root.loaded.saved state. More about pushing into the store in this guide

Hope I helped you.