I would like to get an error message from a store proxy call.
My store looks like this :
Ext.define("MyStore", {
extend: "Ext.data.Store",
model: 'mymodel',
proxy: {
type: 'customrest',
paramsAsJson: true,
url: myUrl,
actionMethods: {
read: 'POST'
},
reader: {
type: 'json',
record: 'result',
root: 'results'
}
},
listeners: {
load: function (store, records, success) {
if (!success) {
}else {
//OK
}
}
}
});
It seems to only give me success is false, and no other information is at hand. I know there is also an error message coming back because the data coming back looks like this :
{success: false, message: "blah blah blah“"}
is there somewhere I can get a handle on 'message'?
UPDATE :
My store is called like this :
this.psstore = Ext.getStore("MyStore");
this.psstore.load({
params: postBody,
callback: function (records, operation, success) {
if (success) {
Check out your reader's messageProperty
:
http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.reader.Json-cfg-messageProperty
so in your config you should have:
reader: {
type: 'json',
record: 'result',
root: 'results',
messageProperty: 'message'
}
You should then be able to get the message through the operation.exception property (IIRC) in the load callback. It's also a parameter passed in the onLoad event (http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.Store-event-load), so you should also be able to access it there. We're using that on Ext 4 with an XML reader and in our upgrade to 6 so it's safe to use.