PDA

View Full Version : Intersecting proxy json and modifying



Thomas The Fourth
5 Mar 2012, 12:48 PM
Hello all,

I'm trying to integrate the yahoo weather api into my application. Unfortunately, the json isn't in a form where I can easily plug it into a store/model and have it just work.

http://weather.yahooapis.com/forecastjson?w=2458833

Is there a place where I could intersect the json and reform it prior to it being put into the store?

Thanks in advance

-Thomas

mitchellsimoens
5 Mar 2012, 1:08 PM
You can hook into the getResponseData method of the reader

Thomas The Fourth
5 Mar 2012, 1:44 PM
Hi Mitchell,

I can't seem to override the method succesfully. It never runs.

Here's my code.

Thanks



Ext.define('app.store.Weather', {
extend : 'Ext.data.Store',
config : {
autoLoad : true,
model : 'app.model.Weather',
sorters : 'date',
},
proxy : {
type : 'jsonp', // ajax is for same domain, jsonp for cross-domain
url : 'http://weather.yahooapis.com/forecastjson?w=2458833',
reader : {
type : 'json',
getResponseData : function(response) {
console.log('getResponseData');
return response;
},
}
},


},
});

mitchellsimoens
5 Mar 2012, 1:49 PM
You will need to create your own reader class