How to use the can-connect/helpers/.getObject function in can-connect

To help you get started, we’ve selected a few can-connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitovi-components / bit-c3 / bit-c3 / node_modules / can-connect / src / data / parse / parse.js View on Github external
parseInstanceData: function( props ) {
			// call any base parseInstanceData
			if(baseConnect.parseInstanceData) {
				// It's possible this might be looking for a property that only exists in some
				// responses. So if it doesn't return anything, go back to using props.
			   props = baseConnect.parseInstanceData.apply(this, arguments) || props;
			}
			return this.parseInstanceProp ? helpers.getObject(this.parseInstanceProp, props) || props : props;
		}
		/**
github bitovi-components / bit-c3 / bit-c3 / node_modules / can-connect / src / data / parse / parse.js View on Github external
parseListData: function( responseData ) {

			// call any base parseListData
			if(baseConnect.parseListData) {
			   responseData = baseConnect.parseListData.apply(this, arguments);
			}

			var result;
			if( isArray(responseData) ) {
				result = {data: responseData};
			} else {
				var prop = this.parseListProp || 'data';

				responseData.data = helpers.getObject(prop, responseData);
				result = responseData;
				if(prop !== "data") {
					delete responseData[prop];
				}
				if(!isArray(result.data)) {
					throw new Error('Could not get any raw data while converting using .parseListData');
				}

			}
			var arr = [];
			for(var i =0 ; i < result.data.length; i++) {
				arr.push( this.parseInstanceData(result.data[i]) );
			}
			result.data = arr;
			return result;
		},