Ember.js & REST API

2019-03-10 22:49发布

From all the various examples of Ember.js, I have not been able to figure out if there is a default method in Ember.js to do REST AJAX calls. Many examples build their own interfaces for CRUD operations. I even tried to sift through the code to find any reference to AJAX calls but came up with nothing.

So, my question is, is there a default implementation of REST API in Ember.js. If yes, how do I use it? Also if, for a specific application, I want to build custom CRUD methods, where do I plug these into Ember.js?

标签: rest ember.js
4条回答
叼着烟拽天下
2楼-- · 2019-03-10 23:02

It seems that Ember Data is what you are looking for. It is part of emberjs organiztion in GitHub.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-03-10 23:03

Ember.js can work nicely with Ember Data. That said, there is a specific format of REST to follow. When followed, you can streamline the process of connecting API with Ember and have so much less work.

In case you use custom REST, the place to adjust is:

  • adapter - to inform from where you like to get data
  • serializer - how data should be adjusted for custom REST API
查看更多
来,给爷笑一个
4楼-- · 2019-03-10 23:09

[2014-02-18: Deprecated - I no longer support ember-rest because it is overly simplistic, and would recommend using ember-data for most ember projects. Check out the Ember guides for an overview of ember-data as well as this example project ]

While learning Ember, I decided to create a very simple Ember REST library. I also wrote an example Rails CRUD app.

My goals were to keep this project as simple as possible, while still including error handling and validation. Ember REST is certainly much leaner than Ember Data and Ember Resource, and I hope you'll find the code well commented and accessible.

查看更多
唯我独甜
5楼-- · 2019-03-10 23:11

There is a Ember Resource library aiming REST JSON interfaces. It provides Ember.Resource class with save(), fetch() and destroy() operations that could be easily overriden. Looks like it should be more mature than Ember Data for now.

查看更多
登录 后发表回答