データストアに新しいレコードを作成した後で、データをAPIに戻しても問題が残っています。Ember:カスタムJSONAPISerializer
// routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return this.store.findAll('user');
},
actions: {
test(name){
this.store.createRecord('user', {
username: name,
email: '[email protected]',
is_staff: false
}).save();
}
}
});
REST APIは、この要求を期待している:
{
"data": {
"type": "User",
"id": null,
"attributes": {
"username": "bill",
"email": "[email protected]",
"is_staff": false
}
}
}
エンバー-データはこれを送信している:ここでは
{
data:
{
attributes:
{
username: "bill",
email: "[email protected]",
is-staff: false
},
type: "users"
}
}
は、私は、カスタム・シリアライザのために持っているものですが、Ember社ではありませんそれを見て。私はこの権利をしていますか?あなたはnormalizeCreateRecordResponse
方法をしようとしている
// routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return this.store.findAll('user');
},
actions: {
test(name){
Ember.$.post('http://localhost:8000/api/users/', {
username: name,
email: '[email protected]',
is_staff: false
});
}
});