Reputation: 2258
I have a rest adapter:
App.Adapter = DS.RESTAdapter.extend({
bulkCommit: true,
url: 'http://10.0.0.106/bank',
ajax: function (url, type, hash) {
hash.url = url;
hash.type = type;
hash.context = this;
hash.headers = {
'Session-Token': '65f1b8925f8eb2780730a4a2993693699e9a98dad5d2995452c24758d2c59706'
};
if (hash.data && type !== 'GET') {
hash.data = JSON.stringify(hash.data);
}
$.ajax(hash);
}
});
App.Store = DS.Store.extend({
revision: 13,
adapter: App.Adapter
});
A route :
App.UsersRoute = Ember.Route.extend({
model: function() {
return App.User.find();
}
});
A model :
App.User = DS.Model.extend({
firstname: DS.attr("string"),
lastname: DS.attr("string"),
email: DS.attr("string"),
user_id: DS.attr("string"),
role: DS.attr("string"),
phone: DS.attr("string")
});
The request work well and give me that :
{
"error": null,
"payload": {
"bank_users": [{
"firstname": "Ugo",
"lastname": "Doe",
"email": "[email protected]",
"user_id": 1,
"role": "BANK_USER",
"phone": null
}, {
"firstname": "Ugo Clone",
"lastname": "Doe",
"email": "[email protected]",
"user_id": 2,
"role": "BANK_USER",
"phone": null
}
]
}
}
In my template; I've just that :
<h2>this is users !!</h2>
{{#each model}}
{{firstname}}
{{/each}}
And the error is : Uncaught TypeError: Cannot call method 'then' of undefined
This happen in ember-data, here :
findAll: function(store, type, since) {
var root, adapter;
root = this.rootForType(type);
adapter = this;
return this.ajax(this.buildURL(root), "GET",{
data: this.sinceQuery(since)
}).then(function(json) {
adapter.didFindAll(store, type, json);
}).then(null, rejectionHandler);
}
I appears that since
is undefined ; What I am doing wrong ? :)
Upvotes: 0
Views: 672
Reputation: 23322
I guess, since you are overriding the RESTAdapter
ajax
method should the last line
$.ajax(hash);
not rather be?
return $.ajax(hash);
Hope it helps.
Upvotes: 1