![](/img/trans.png)
[英]Ember-data “Assertion Failed: Error: Assertion Failed: The response from a findAll must be an Array, not undefined”
[英]ember.js Error: Assertion Failed: The response from a findAll must be an Array, not undefined
也許這是有史以來最愚蠢的問題,但仍然 - 如何手動查詢服務器以獲取特定模型的記錄?
App.UrlNewRoute = Ember.Route.extend({
setupController: function(controller, model) {
console.dir(1);
this.store.find('UrlType').then(function(url_types) {
controller.set('urlTypes',url_types);
});
}
});
{"url_types":[{"id":1,"caption":"text link"},{"id":2,"caption":"guest post"},{"id":3,"caption":"blog comment"},{"id":4,"caption":"banner"},{"id":5,"caption":"profile"},{"id":6,"caption":"review"}]}
完全合法的問題,
你應該使用camelCase
查詢它:
this.store.find('urlType')
你的json密鑰也應該是camelCase
(你也可以使用序列化程序修復它):
{
"urlTypes":[
{
"id":1,
"caption":"text link"
},
{
"id":2,
"caption":"guest post"
},
{
"id":3,
"caption":"blog comment"
},
{
"id":4,
"caption":"banner"
},
{
"id":5,
"caption":"profile"
},
{
"id":6,
"caption":"review"
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.