Closed
Description
My server gives me properties with names like first_name
and I don't like dealing with that in my code (I'd rather camel case it). So this is what I have:
app.config(function (DSHttpAdapterProvider) {
// Because I don't want to deal with snake_case properties in here...
// I convert to camel on the way in
DSHttpAdapterProvider.defaults.serialize = function serialize(resourceName, attrs, cb) {
cb(null, attrs.map(function snakeToCamel(s) {
return s.replace(/(\_\w)/g, function(m){
return m[1].toUpperCase();
});
}));
};
// I convert to snake on the way out
DSHttpAdapterProvider.defaults.deserialize = function deserialize(resourceName, attrs, cb) {
cb(null, attrs.map(function camelToSnake(s) {
return s.replace(/([A-Z])/g, function(m) {
return '_' + m.toLowerCase();
});
}));
};
});
But I'm getting undefined errors on DSHttpAdapterProvider.defaults
, so I've tried it without the defaults
and I tried putting it on DSProvider.defaults
just for fun, but it's never called in those cases. What am I doing wrong?