如何使用ember.js的RestAdapter连接外部API(不在我的服务器域上)?
答案 0 :(得分:0)
假设您正在使用Ember数据。
您将很难为单个模型多次调用不同的端点,然后创建模型。我建议使用原始ajax,然后将数据加载到商店中。
以下是有关Ember Data的侧载的说明
/**
Push some raw data into the store.
The data will be automatically deserialized using the
serializer for the `type` param.
This method can be used both to push in brand new
records, as well as to update existing records.
You can push in more than one type of object at once.
All objects should be in the format expected by the
serializer.
```js
App.ApplicationSerializer = DS.ActiveModelSerializer;
var pushData = {
posts: [
{id: 1, post_title: "Great post", comment_ids: [2]}
],
comments: [
{id: 2, comment_body: "Insightful comment"}
]
}
store.pushPayload('post', pushData);
```
@method pushPayload
@param {String} type
@param {Object} payload
*/