我在尝试呼叫休息api时遇到此错误:遭遇"公司"在有效负载中,但没有找到型号名称"公司"
的模型http://localhost:9000/api/insurance/travel/companies
致电示例:
var companies = this.store.find("insurance/travel/company");
型号:
export default DS.Model.extend({
name: DS.attr('string'),
url: DS.attr('string'),
logoUrl: DS.attr('string'),
contactUrl: DS.attr('string'),
moreUrl: DS.attr('string'),
about: DS.attr('string')
})
JSON示例:
{
"companies": [
{
"id": "id1",
"name": "test",
"url": "http://google.com",
"logoUrl": "http://google.com",
"contactUrl": "http://google.com",
"moreUrl": "http://google.com",
"about": "about text"
},
{
"id": "id2",
"name": "test 2",
"url": "http://google.com",
"logoUrl": "http://google.com",
"contactUrl": "http://google.com",
"moreUrl": "http://google.com",
"about": "about text"
}
]
}
答案 0 :(得分:0)
创建适配器并注入变形器
import DS from 'ember-data';
import Ember from 'ember';
var inflector = Ember.Inflector.inflector;
inflector.uncountable('company');
export default DS.RESTAdapter.extend({});
它对我有用