「我試圖使Emberjs與fortunejs後端一起工作。到目前爲止,我在Ember中做了一個非常簡單的頁面,該頁面應該顯示所有'客戶'實體,它們與LSadapter一起工作良好。「斷言失敗:來自findAll的響應必須是數組,而不是未定義的」
當我的應用程序加載概述頁面,它做一個GET請求http://localhost:1337/customers
和財富與迴應:
{
"customers": [
{
"id": "YIR17juOFkaWBFhl",
"name": "PIm",
"phone": 132,
"fax": 123,
"chamberOfCommerceNumber": 123,
"website": "123.nl"
},
{
"id": "gUGIoHvwI8mwVTgE",
"name": "Marco",
"phone": 123,
"fax": 123,
"chamberOfCommerceNumber": 123,
"website": "it.nl"
}]}
然而,燼似乎並不喜歡它,並給了我:
「聲明失敗:來自findAll的響應必須是數組,而不是 undefined」
我以爲這個是正確的json格式燼從期望得到所有客戶的請求,出了什麼問題?
僅供參考,我創建了一個可以在fortunejs下正常工作的創建頁面。爲此,我必須像這樣修改RESTSerializer:
App.ApplicationSerializer = DS.RESTSerializer.extend({
serialize: (record, options) ->
[this._super record, options] #Turn into array
serializeIntoHash: (hash, type, record, options) ->
console.log type.typeKey
type.typeKey = Ember.Inflector.inflector.pluralize type.typeKey #pluralize root key
console.log type.typeKey
console.log record
result = this._super hash, type, record, options
});
但是,這應該與傳入的JSON形式的api無關。
任何想法出了什麼問題?