Adapting to an API that includes metadata

I have to extract data from a source that sends meta-data. Presently, it sends an object with two properties,

{
metadata: blah,
data: normal data list
}

I added a jquery.prefilter() and also a data filter property to allow me to condition the data. Basically, I strip the metadata and place the data part into the data structure. It works great on the return data from a save(). But for a get(), it REJECTS the promise.

I’m using code I extracted from bitable…

users: {
	get: function() {
		var list=User.getList({});
		return list;
	}
}

It worked fine with a simple test fixture before I found I had to deal with the metadata. Once I switched to the complicated data source and added the pre-conditioning mechanism, it’s busted.

With the data filter, the data gets to the map held by ‘list’. It just never resolves. Turns out it’s a .catch(e) in the fall-through-cache.

I’m guessing that the cache is doing it’s own datafilter before mine runs. Is there a mechanism in this kit that will let me be the very first to touch the data stream so that the other automatic stuff will be operating on the data stream I shape?

I could get the metadata moved to the header but I can’t figure out how to access the header either incoming or outbound for donejs.

Is that a better alternative? How?

Thanks.

you can supply your own getListData, getData, etc functions to the url option as is shown at the bottom of: http://canjs.github.io/canjs/doc/can-connect/data/url/url.url.html

alternatively, there’s the configuration options in: http://canjs.github.io/canjs/doc/can-connect/data/parse/parse.html

Data/parse worked PERFECTLY!! Thank you very much.

I found one weird thing I wonder about.

I have, at this point, two models that use parseInstanceData(individualItem). Oddly, one of them receives individualItem as JSON and the other receives an object. I can see no difference to account for this. The parseListData() is identical in each.