@anaspm wrote:
i am using mirage for mock server with ember application
while doing insert and delete am getting this error
Assertion Failed: An adapter cannot assign a new id to a record that already has an id. had id: 4 and you tried to update it with null. This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.
I have following code in config.js of mirage
this.get('/employees', function(store, request) { return { data: store.employees.map(attrs => ( {type: 'employees', id: attrs.id, attributes: attrs } )) };
}); this.get('/employees/:id',function(db, request) { return { data: db.employees.map(attrs => ( {type: 'employees', id: attrs.id, attributes: attrs } )) }; }); this.post('/employees', function(store, request) { let attrs = JSON.parse(request.requestBody).employee; let employee = store.employees.insert(attrs); console.log(employee); /*return { data: employee };*/ return { data: store.employees.map(attrs => ( {type: 'employees', id: attrs.id, attributes: attrs } )) }; }); this.del('/employees/:id',function(store, request) { //console.log(attrs.id); var id = request.params.id; console.log(id); store.employees.remove(id); return { data: store.employees.map(attrs => ( {type: 'employees', attributes: attrs } )) }; });
Posts: 1
Participants: 1