Saturday, 15 June 2013

javascript - RESTAdapter not working with Ember -



javascript - RESTAdapter not working with Ember -

i working ember , attempting retrieve info rest api, not working intended. first of quite unsure how debug restadapters , sec of don't see phone call beingness made in chrome devtools network view.

html:

<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script> <script src="http://builds.emberjs.com/release/ember.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.0.0-beta.11/ember-data.js"></script>

here js:

app = ember.application.create(); app.store = ds.store.extend({ adapter: ds.restadapter.extend({ host: 'http://example.com/api' }) }); app.bodypart = ds.model.extend({ name: ds.attr('string') }); app.applicationroute = ember.route.extend({ model: function() { homecoming app.bodypart.find(); } });

my console returns:

error while processing route: index undefined not function typeerror: undefined not function

i understand means returning null pointer or empty model.

so question arrises, how debug restadapter?

you seem using old ember-data syntax , applying 1.0beta11. don't have link @ moment, check on official repository or guides. model hook in route should alter from:

return app.bodypart.find();

to

return this.store.find('bodypart');

also seem declaring adapter incorrectly well. should be:

app.applicationadapter = ds.restadapter.extend({ host: 'http://example.com', namespace: 'api' });

also, consider changing request applicationroute kid route, or may experience "fake frozen" application shown here

javascript ember.js ember-data

No comments:

Post a Comment