我目前运行的服务器提供这样的数据:
单一实体
{"id":"11","name":"hello",....}
实体清单
[{single entity format},{},...]
但是,Ember Data 期望数据遵循JSON API 规范,格式为
{"entity":{"id":"11","name":"hello",....}} OR {"entities":[{},{},{}...]}
否则它将返回错误:
Your server returned a hash with the key 0 but you have no mapping for it
我目前有一个responseFactory
将响应构建为映射,其中键是 ember 模型(“用户”/“用户”)实体/列表和值是列表/实体本身
有没有更好/更清洁的方法?