簡體   English   中英

ember.js錯誤:斷言失敗:來自findAll的響應必須是一個數組,而不是未定義

[英]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"
      }
   ]
}

http://emberjs.jsbin.com/OxIDiVU/301/edit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM