0
votes

I have a service that needs to be invoked with POST instead of a GET. I thought that I read somewhere that I could simply add the method: 'POST' option on the proxy, but it doesn't seem to have an effect.


    Ext.define('Sencha.store.Teams', {
        extend: 'Ext.data.Store',

        config: {
            model: 'Sencha.model.Team',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                // method: 'GET',

                method: 'POST',
                url: 'teams.json'
            }
        }
    });

1

1 Answers

5
votes

You have to override actionMethod property

Ext.define('Sencha.store.Teams', {
    extend: 'Ext.data.Store',

    config: {
        model: 'Sencha.model.Team',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            actionMethods: {
                create : 'POST',
                read   : 'POST', // by default GET
                update : 'POST',
                destroy: 'POST'
            },
            url: 'teams.json'
        }
    }
});

or define your own proxy class

Ext.define('Sencha.data.PostAjax', {
    extend: 'Ext.data.proxy.Ajax',
    alias: 'proxy.postproxy', // must to get string reference
    config: {
       actionMethods: {
            create : 'POST',
            read   : 'POST', // by default GET
            update : 'POST',
            destroy: 'POST'
        },
    }
}


Ext.define('Sencha.store.Teams', {
    extend: 'Ext.data.Store',

    config: {
        model: 'Sencha.model.Team',
        autoLoad: true,
        proxy: {
            type: 'ajaxpost'
            url: 'teams.json'
        }
    }
});

Disclaimer: code was written from scratch and not really tested. Please do not downvote if it does not work, before not get replay on your comment. Thanks.