1
試圖返回從JSON API結果時,我發現了以下錯誤在我的控制檯:加載時出錯路線:錯誤:斷言失敗:從的findAll的響應必須是一個數組,而不是不確定的
錯誤而載入路線:錯誤:斷言失敗:從的findAll的響應必須是一個數組,而不是未定義
灰燼數據包含來自我的JSON API數據(參見圖)
除此之外,我的代碼沒有發生錯誤。
任何想法?
恩伯APP:
App = Ember.Application.create();
App.ApplicationAdapter = DS.RESTAdapter;
App.ApplicationAdapter = DS.RESTAdapter.extend({
url: 'http://127.0.0.1:3000',
namespace: 'api'
});
App.ApplicationSerializer = DS.RESTSerializer.extend({
primaryKey: '_id'
});
App.Store = DS.Store.extend({
revision: 11,
adapter: 'App.Adapter'
});
App.Users = DS.Model.extend({
"firstName": DS.attr('string'),
"secondName": DS.attr('string'),
"shortName": DS.attr('string'),
"emailAddress": DS.attr('string'),
"password": DS.attr('string'),
"group": DS.attr('string'),
"charisma": DS.attr('string'),
"focus": DS.attr('string'),
"strength": DS.attr('string'),
"dexterity": DS.attr('string'),
"userType": DS.attr('string'),
"dressType": DS.attr('string'),
"skinType": DS.attr('string'),
"__v": DS.attr('string'),
"loggedInDate": DS.attr('string'),
"loggedIn": DS.attr('string'),
"dateRegistered": DS.attr('string')
});
App.User = DS.Model.extend({
"firstName": DS.attr('string'),
"secondName": DS.attr('string'),
"shortName": DS.attr('string'),
"emailAddress": DS.attr('string'),
"password": DS.attr('string'),
"group": DS.attr('string'),
"charisma": DS.attr('string'),
"focus": DS.attr('string'),
"strength": DS.attr('string'),
"dexterity": DS.attr('string'),
"userType": DS.attr('string'),
"dressType": DS.attr('string'),
"skinType": DS.attr('string'),
"__v": DS.attr('string'),
"loggedInDate": DS.attr('string'),
"loggedIn": DS.attr('string'),
"dateRegistered": DS.attr('string')
});
App.Router.map(function() {
// put your routes here
});
App.IndexRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render('nav', {
outlet: 'nav'
});
},
model: function() {
return this.store.find('users');
}
});
JSON
{
"Users": [
{
"firstName": "Berniece",
"secondName": "Bergstrom",
"shortName": "april",
"emailAddress": "[email protected]info",
"password": "PRPOP",
"group": 1,
"charisma": 4,
"focus": 3,
"strength": 3,
"dexterity": 1,
"userType": 1,
"dressType": 2,
"skinType": 1,
"_id": "5302604e1a41219a2d2072eb",
"__v": 0,
"loggedInDate": "2014-02-17T19:17:34.725Z",
"loggedIn": false,
"dateRegistered": "2014-02-17T19:17:34.724Z"
},
{
"firstName": "Lamar",
"secondName": "Schneider",
"shortName": "august.blick",
"emailAddress": "[email protected]",
"password": "PJPUK",
"group": 0,
"charisma": 2,
"focus": 3,
"strength": 1,
"dexterity": 2,
"userType": 1,
"dressType": 2,
"skinType": 2,
"_id": "5302604e1a41219a2d2072ec",
"__v": 0,
"loggedInDate": "2014-02-17T19:17:34.728Z",
"loggedIn": false,
"dateRegistered": "2014-02-17T19:17:34.728Z"
}
}