How to get / receive REST data using ember data?

I was looking at the documentation for a REST adapter that was packed with ember data, but I can not find any information on how ember actually makes a json request to the server, or how to get or access the data after it has done request using this adapter (the documentation on the ember data data page seems to boil down to porting your own adapter, except for a small paragraph on how to specify whether to disable bulk commits, although maybe I'm just missing something )

+4
source share
1 answer

You must tell your store to use DS.RESTAdapter , and this handles communication with your server using AJAX calls, see the basic example here

You can get a general overview of how the RESTAdapter used in tests .

 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(); 

+8
source

Source: https://habr.com/ru/post/1402722/


All Articles