I have a service to get the current user and it returns correctly when I return a hardcoded object, but I can't get it to return data from an ajax call.
export default Ember.Service.extend({
currentUser: Ember.computed(function() {
Ember.$.ajax({
url: "http://localhost:8000/v1/me/"
}).then(function(data){
console.log(data);
return data;
},
function(err){
console.log(err);
});
}),
});
I know the data is being returned correctly, according to the console.log
in the promise.
When I use this service in a controller, it is returning nothing for the currentUser, however I know everything is hooked up correctly because if i substitute an Ember.Object in for the ajax query, it returns that object to the Controller.
Do I need to do something special with the property that contains the ajax query to be able to use the returned data in a controller?
Aucun commentaire:
Enregistrer un commentaire