作为Ember.js的初学者,我尝试从我的Rails Api服务器将一些数据提取到Ember App。我的Ember应用程序试图从rails api获取并显示服务的类别名称。 我使用Ember js错误:适配器操作失败
- 灰烬版本:1.13.8
- 节点:0.12.7
- NPM:2.13.4
应用程序/ router.js
Router.map(function() {
this.resource('categories',function(){
this.resource('category',{path: '/:category_id'});
});
});
routes/categories/index.js
export default Ember.Route.extend({
model() {
return this.store.findAll('category')
}
});
应用程序/模型/ category.js
export default DS.Model.extend({
name: DS.attr('string')
});
应用程序/适配器/ application.js中
export default DS.JSONAPIAdapter.extend({
shouldReloadAll: function() { return true; },
namespace: 'v1',
host: 'http://ip.address-to_rails_api'
});
应用/模板/分类/ index.hbs
<ul>
{{#each model as |category|}}
<li>{{category.name}}</li>
{{/each}}
</ul>
现在,当我请在我的浏览器中访问http://ip.address-to_rails_api我收到回复
{"categories":[{"id":1,"name":"Entertainment"}, {"id":2,"name":"Education"}]}
但是当我参观我的余烬应用IE /类别http://localhost:4200/categories 关注的是浏览器中显示和我在灰烬检查得到错误
routeName: "categories.index_error"
context: Error: Adapter operation failed
currentModel: Error: Adapter operation failed
而且余烬服务器控制台上反映的错误
Content Security Policy violation: {}
我也尝试将JSONAPIAdapter更改为RESTAdapter,但它提供了弃用错误。请帮我理解这个问题。
我面临着同样的问题,这里的http://计算器。COM /问题/ 32670533 /烬测试错误,适配器操作失败。不幸的是,我现在还没有解决方案 – Rigel
有一点需要注意的是,我认为在1.13.8之前已经弃用了“资源”。 – sheriffderek
是的,我改变了资源路线,但问题是别的。 在烬引起的主要问题是由于代码的指数变化。他们正在以非常快的速度改变它,所以每个月后都会被弃用。 –