PDA

View Full Version : Multiple Delete Requests lead to 404 NetworkError / REST JSON Proxy



Tatonka
15 Oct 2012, 12:14 AM
Hi,

I am using a REST proxy for my Ext store which seems to work well.


Ext.define('ExtApp.store.Sets', {
extend: 'Ext.data.Store',
requires: 'ExtApp.model.Set',
model: 'ExtApp.model.Set',

id: 'setsStore',

pageSize : 500,
autoLoad: true,
autoSync: false,

proxy: {
type: 'rest',
url: '/api/sets',
appendId: true,

extraParams : {'token': API_TOKEN, 'authenticity_token': AUTHENTICITY_TOKEN },
reader:{
type: 'json',
root: 'sets'
},
},
....


The problem then appears when I delete a record and sync. The first DELETE request is handled fine by the server, but apparently the action is not recognized by the Ext store. When syncing again, I get a 404 NetworkError, stating the id is no longer valid (which makes sense, since it has been deleted).


DELETE http://localhost:3000/api/sets/51?_dc=1...%3D (200 OK, 63ms)
DELETE http://localhost:3000/api/sets/51?_dc=1...%3D (404 Not Found, 25ms)

Does the store expect the server to send a specific response to recognize the success?

Thanks for the help
T.

vietits
15 Oct 2012, 1:07 AM
The answer is yes. You should return a response to tell the store that the action is successful.

Tatonka
15 Oct 2012, 1:10 AM
Just an empty response or does it need to say something specific?
The server now returns a 200 OK, which in itself seems good to me.

Thanks
T.

vietits
15 Oct 2012, 1:53 AM
For delete action, I often return {"success": true};

Tatonka
15 Oct 2012, 4:00 AM
Cool .. thanks that did the job.

Thanks for the help.

T.