cyclomarc
cyclomarc

Reputation: 2012

Ember data: How to specify usage of REST adapter in recent Ember version?

I simply want to change the data fetching froom a fixture adapter to a REST adapter. I cannot find the correct syntax in the documentation ... Whatever I try, no JSON call is executed against the REST interface.

can somebody help ?

ps. When I simply use a JQuery call (return $.getJSON('http://localhost:3000/articles.json');), this works, but as mentioned above, I would like to use the Ember REST adapter ...

My model:

App.Article = DS.Model.extend({
  title: DS.attr('string'),
  author: DS.attr('string'),
  body: DS.attr('string')
});

My fixures adapter:

App.Store = DS.Store.extend({
  revision: 12,
  adapter: 'DS.FixtureAdapter'
});

My REST adapter (NOT WORKING)

App.Store = DS.Store.extend({
  revision: 12,
  adapter: DS.RestAdapter.create({
    url: 'http://localhost:3000'
  })
});

My route

App.ArticleRoute = Ember.Route.extend({
  model: function () {
    App.Article.find();
    //return $.getJSON('http://localhost:3000/articles.json');
  }

});

Upvotes: 3

Views: 5121

Answers (1)

intuitivepixel
intuitivepixel

Reputation: 23322

You have the class name wrong, it needs to be DS.RESTAdapter instead of DS.RestAdapter

Try this:

App.Store = DS.Store.extend({
  revision: 12,
  adapter: DS.RESTAdapter.create({
    url: 'http://localhost:3000'
  })
});

Hope it helps.

Upvotes: 5

Related Questions