hodgesmr
hodgesmr

Reputation: 2785

Ember.js external json for Store

I have a json file that lives on the on the server that is hosting my Ember.js app. I want to use that json as the "store" for the app (it will only be for reading). I'm not sure the best way to do this. Do I need to use a RESTAdapter to hit the file, or somehow use it as an external FixtureAdapter, or is there some other way to accomplish this?

Upvotes: 1

Views: 269

Answers (1)

GJK
GJK

Reputation: 37369

Your best bet is to use the fixture adapter as described here. If the file is static, you can just add it to your page as a script tag and be done with it. If the file changes per user, you'll probably have to write some server-side logic to generate it. If that's the case, I would append it to your HTML file as a self executing function or something. Either way, if your data isn't changing, the FixtureAdapter is your best bet. You don't want to have to mess with the RESTAdapter or trying to write your own.

Upvotes: 2

Related Questions