내 API에서 데이터를 가져 오려면 최신 버전의 ember-data (버전 11) 및 REST 어댑터를 사용하고 있습니다. 반환 된 JSON의 샘플은 다음과 같습니다Ember 데이터 매핑
{
"events": [
{
"id": "5118dd8c4c80866ef2000051",
"title": null,
"starts_at": 1361901600,
"ends_at": null,
"currency": "SEK",
"cents_door": 4000,
"cents_advance": null,
"price_door": "40.00 kr",
"price_advance": null,
"age_limit": null,
"venue_section": "PLAYHOUSE",
"description": null,
"url": null,
"repeats": null,
"repeats_until": null,
"venue_id": "nefertiti-jazz-club",
"act_ids": [ "marias-playhouse" ]
}
]
}
모델은 다음과 같습니다
App.Event = DS.Model.extend
title: DS.attr('string')
startsAt: DS.attr('number')
endsAt: DS.attr('number')
currency: DS.attr('string')
centsDoor: DS.attr('number')
centsAdvance: DS.attr('number')
priceDoor: DS.attr('string')
priceAdvance: DS.attr('string')
ageLimit: DS.attr('string')
venueSection: DS.attr('string')
description: DS.attr('string')
url: DS.attr('string')
repeats: DS.attr('string')
repeatsUntil: DS.attr('string')
venue: DS.belongsTo('App.Venue')
acts: DS.hasMany('App.Act')
을하지만 데이터를 요청할 때, 요청이 성공적으로 완료,하지만 난 콘솔에서이 오류가 발생합니다 :
Uncaught Error: assertion failed: Your server returned a hash with the key events but you have no mapping for it
어떤 아이디어가 잘못 되었나요?
===
UPDATE : 내 Ember.js 응용 프로그램의 좀 더 추가 해요 요청으로.
내 RESTAdapter 설정 :
DS.RESTAdapter.registerTransform 'raw',
deserialize: (serialized) ->
serialized
serialize: (deserialized) ->
deserialized
App.Store = DS.Store.extend
adapter: DS.RESTAdapter.create
url: LJ.CONFIG.api.url
revision: 11
그리고 노선 :
App.Router.map ->
this.resource 'events', ->
this.route 'new'
this.resource 'event', path: '/events/:event_id', ->
this.route 'edit'
this.resource 'venue', path: '/venues/:venue_id', ->
this.route 'edit'
this.resource 'events'
this.resource 'act', path: '/acts/:act_id', ->
this.route 'edit'
this.resource 'events'
this.route 'search', path: '/search/:term'
this.route 'doc', path: '/docs/:doc'
와트? 구문을 수정하고 더 설명 할 수 있습니까? 아직도 관련이 있습니까? – netpoetica