ExtJs, how to send JSON on store.load() using POST method

10,188

It is likely that you are looking for proxy config option paramsAsJson:true

Share:
10,188
Peter
Author by

Peter

Updated on June 04, 2022

Comments

  • Peter
    Peter almost 2 years

    I need to send JSON object during read operation on store. Headers and method are set correctly.

    var proxyDefinition = {
        type : 'rest',
        api : {
            read : '/some/url'
        },
        actionMethods : {
            create  : 'POST',
            read    : 'POST',
            update  : 'PUT',
            destroy : 'DELETE'
        },
        reader : {
            type : 'json'
        }        
    };
    
    var store = Ext.create('Ext.data.Store', {
        proxy : proxyDefinition,
        model : 'SomeModel'
    });
    
    // this needs to send JSON
    store.load({
        params : {
            filter: [] // some filtering rules
        }
    });
    

    Problem is that POST body is sent as url encoded query string, not JSON object with property "filter".

    ExtJs version 4.2.2

  • otocon
    otocon almost 7 years
    But what to do, if you want to make POST request and send some params as query params, rest as request payload?