简体   繁体   English

如何使用ember-data获取/检索我的REST数据?

[英]How do I get / retrieve my REST data using ember-data?

我一直在搜索与ember数据一起打包的REST适配器的文档,但我似乎无法找到有关如何实际让ember向服务器发出json请求或如何检索或访问数据的任何信息一旦它使用这个适配器发出请求(ember-data页面上的文档似乎都是关于滚动你自己的适配器,除了关于如何指定你是否需要禁用批量提交的小段落,尽管我可能只是遗漏了什么 )

You have to tell your store to use the DS.RESTAdapter and this handles the communication with your server via AJAX calls, see a basic example here 您必须告诉您的商店使用DS.RESTAdapter并通过AJAX调用处理与服务器的通信,请参阅此处的基本示例

You can get a basic overview how the RESTAdapter is used in the tests . 你可以得到一个基本概述如何RESTAdapter在使用测试

App = Ember.Application.create({});

App.store = DS.Store.create({
    revision: 3,
    adapter: DS.RESTAdapter.create({
        ajax: function(url, type, hash) {
            console.log(arguments);
        }
    })
});

App.Person = DS.Model.extend({
});

App.Person.createRecord({
});

// tell the store to contact REST service
App.store.commit();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM