src/sdk.js
function _multiCallback(serverError, serverResponse, callback, interleave, requestedIds){
  var clientResponse = {};
  
  // Handle response errors
  _.each(serverResponse, function(data, id){
    var thisError = serverError;
    if(serverError && data.status.code !== 200){
      thisError = new Error(data.status.msgs.join('. '));
      thisError.code = data.status.code;
    }
    clientResponse[id] = {
      error:  thisError,
      data: data.data
    };
  });
  
  // Handle request level errors
  if(serverError && !serverResponse){
    _.each(requestedIds, function(id){
      if(_.isUndefined(clientResponse[id])){
        clientResponse[id] = {
          error: serverError,
          data: null
        };
      } 
    });
  }
  
  // Interleave validation errors
  if(interleave){
    _.extend(clientResponse, interleave);
  }
  
  callback(clientResponse);
}
function _multiCallback(serverError, serverResponse, callback, interleave, requestedIds){
  var clientResponse = {};
  
  // Handle response errors
  _.each(serverResponse, function(data, id){
    var thisError = serverError;
    if(serverError && data.status.code !== 200){
      thisError = new Error(data.status.msgs.join('. '));
      thisError.code = data.status.code;
    }
    clientResponse[id] = {
      error:  thisError,
      data: data.data
    };
  });
  
  // Handle request level errors
  if(serverError && !serverResponse){
    _.each(requestedIds, function(id){
      if(_.isUndefined(clientResponse[id])){
        clientResponse[id] = {
          error: serverError,
          data: null
        };
      } 
    });
  }
  
  // Interleave validation errors
  if(interleave){
    _.extend(clientResponse, interleave);
  }
  
  callback(clientResponse);
}
function _multiCallback ( serverError , serverResponse , callback , interleave , requestedIds ) { var clientResponse = { } ; // Handle response errors _ . each ( serverResponse , function ( data , id ) { var thisError = serverError ; if ( serverError && data . status . code !== 200 ) { thisError = new Error ( data . status . msgs . join ( '. ' ) ) ; thisError . code = data . status . code ; } clientResponse [ id ] = { error : thisError , data : data . data } ; } ) ; // Handle request level errors if ( serverError && ! serverResponse ) { _ . each ( requestedIds , function ( id ) { if ( _ . isUndefined ( clientResponse [ id ] ) ) { clientResponse [ id ] = { error : serverError , data : null } ; } } ) ; } // Interleave validation errors if ( interleave ) { _ . extend ( clientResponse , interleave ) ; } callback ( clientResponse ) ; }
Callback used by Multi methods that
generates the proper response format
Callback used by Multi methods that generates the proper response format