【发布时间】:2015-09-16 14:17:48
【问题描述】:
我被困在尝试使用 Ember-Data 1.3 的 to.save() 记录 ????
当我执行 .save() 时没有任何问题,但请求有效负载为空:
我非常确信这是 ember-data 请求的问题,因为从后端我得到的唯一数据是“token=blahblahblah”。我也接受了请求(复制为 cURL)并确认它是空的:
这是 .save() 代码:
var self = this;
this.set('isLoading',true);
return this.store.find('feed', feed_id).then(function(feed) {
//Setting the system_status of the feed to either 4 (archived) or 1 (normal)
feed.set('system_status',param);
//Persist to change to store (and server)
console.log(feed);
feed.save().then(function(){
//success
self.set('isLoading',false);
alert('ok');
},function(){
//Error
self.set('isLoading',false);
alert('error');
}) // => PUT to /feeds/id
});
REST 适配器:
export default DS.RESTAdapter.extend({
host: 'http://localhost:8000/',
namespace: 'ed',
headers: {
"Content-type": "x-www-form-urlencoded" // workaround for laravel
}});
.save() 之前的模型 console.log
有什么想法吗?
【问题讨论】:
-
问题可能出在序列化程序中。能否请您也提供它的代码?
标签: ember.js ember-data