src/apiWrapperService.js
/**
		* Takes data and appends it to formData. formData is the browser's FormData implementation or the fake implementation
		* for non-supportive browsers
		* @param <Object, Array> data		Object of data to be sent with request
		* @param <Object> formData			FormData() or FakeFormData() to which data is appended
		*/
Takes data and appends it to formData. formData is the browser's FormData implementation or the fake implementation
for non-supportive browsers
@param  data           Object of data to be sent with request
@param  formData                      FormData() or FakeFormData() to which data is appended
Takes data and appends it to formData . formData is the browser ' s FormData implementation or the fake implementation for non - supportive browsers @param data Object of data to be sent with request @param formData FormData () or FakeFormData () to which data is appended
function generateFormDataFromData( data, formData ) {
			if( angular.isObject( data ) ) {
				for( var i in data ) {
					if( angular.isObject( data[ i ] ) ) {
						if( window.File && data[ i ] instanceof File ) {
							formData.append( i, data[ i ] );
						}
						else {
							generateFormDataFromData( data[ i ], formData );
						}
					}
					else if( typeof data[ i ] === 'string' || typeof data[ i ] === 'number' || typeof data[ i ] === 'boolean' ) {
						formData.append( i, data[ i ] );
					}
					else if( data === undefined || data === null ) {
						formData.append( i, '' );
					}
				}
			}
			else if ( angular.isArray( data ) ) {
				for( var j = 0; j < data.length; j++ ) {
					generateFormDataFromData( data[ j ], formData );
				}
			}
			else {
				console.error( 'APIWrapperService: Unknown type was passed to generateFormDataFromData: %o', data );
			}
			return formData;
		}
function generateFormDataFromData ( data , formData ) { if ( angular . isObject ( data ) ) { for ( var i in data ) { if ( angular . isObject ( data [ i ] ) ) { if ( window . File && data [ i ] instanceof File ) { formData . append ( i , data [ i ] ) ; } else { generateFormDataFromData ( data [ i ] , formData ) ; } } else if ( typeof data [ i ] === 'string' || typeof data [ i ] === 'number' || typeof data [ i ] === 'boolean' ) { formData . append ( i , data [ i ] ) ; } else if ( data === undefined || data === null ) { formData . append ( i , '' ) ; } } } else if ( angular . isArray ( data ) ) { for ( var j = 0 ; j < data . length ; j ++ ) { generateFormDataFromData ( data [ j ] , formData ) ; } } else { console . error ( 'APIWrapperService: Unknown type was passed to generateFormDataFromData: %o' , data ) ; } return formData ; }
Takes data and appends it to formData.
Takes data and appends it to formData .
// Object // Go through data's properties // Object // File // Not a file  // String, number, boolean // undefined, null: send empty String // Array // Add data recursively // Append data recursively // Unknown