I have backend that serve this json
{
"bars": [
{
"Id": 1,
"Name": "one bar"
},
{
"Id": 2,
"Name": "second bar"
},
{
"Id": 3,
"Name": "third bar"
}
]
}
at host: 'http://localhost:3000/bars'
this is all what I have on the client side:
;(function(Ember, DS) {
var App = Ember.Application.create({
LOG_TRANSITIONS: true
});
window.App= App;
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://localhost:3000'
});
App.ApplicationSerializer = DS.JSONSerializer.extend({
primaryKey: 'id'
});
App.Bar = DS.Model.extend({
name: DS.attr('string')
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
var bars = this.store.find('bar');
bars.then(function(bars) {
console.log(bars.toString()); // I'm getting an empty array !
});
return bars;
}
});
}(Ember, DS));
I'm using
Ember : 1.9.0
Ember Data : 1.0.0-beta.14.1
Handlebars : 2.0.0
jQuery : 2.1.1
PS: the jquery ajax request seems working normaly:
XHR finished loading: GET "http://localhost:3000/bars".
Aucun commentaire:
Enregistrer un commentaire