I am currently having an issue learning the basics of Ember and how it communicates with a backend service.
Here is what I'm doing in router.js
:
Rugby.RugbyRosterRoute = Ember.Route.extend({
model: function(){
return [{
firstname:$.getJSON("/RugbyAPI")
// $.getJSON("/RugbyAPI") returns "John"
}];
//return this.store.find('roster');
},
renderTemplate: function(controller) {
this.render('rugby/roster', {controller: controller});
// tried this as well
//this.render('rugby/roster', controller);
}
});
But this is whats rendered.... [object Object]
I guess my question is how would I deal with this 'object'. I have been stuck for the past day but now luck...
EDIT:
I run this command in the web browser console...
$.getJSON("/RugbyAPI", function(data) { console.log(data) });
This is the result:
-> Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
-> John
My guess is that I have to parse to the key that I need to display... But I can't seem to parse to it.... ['responseJSON']
, ['firstname']
, etc., nothings working...