How can I prevent Ext JS from including an entity body in DELETE requests using a restful store?

后端 未结 2 1425
醉梦人生
醉梦人生 2021-01-18 11:12

When Ext JS issues a DELETE request from a restful store, it includes an entity body. Although this doesn\'t seem to be forbidden by the HTTP spec, Google App Engine doesn\'

2条回答
  •  无人共我
    2021-01-18 11:40

    Although the question is asked 7 years ago and we have sencha 6 now, the problem isn't solved OOTB yet. So here is my working solution:

    Ext.define('My.Proxy', {
        extend: 'Ext.data.proxy.Rest',
        writer: {
            type: 'json',
            writeAllFields: true, // may be false, as you wish
            transform: {
                fn: function(data, request) {
                    return request.config.action === 'destroy' ? null : data;
                },
                scope: this
            }
        }
    });
    

    We could also do this check: request.config.method === 'DELETE' but for some reason it always returns false. So I recommend to stay with action === 'destroy'

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题