strong-error-handler icon indicating copy to clipboard operation
strong-error-handler copied to clipboard

Support custom jsonSerializer

Open bajtos opened this issue 9 years ago • 0 comments

See https://github.com/strongloop/loopback/issues/1650#issuecomment-161920555

  // a custom JSON serializer function for producing JSON response bodies
  // @param sanitizedData: response data containing only safe properties
  // @param originalError: the original Error object
  jsonSerializer: function(sanitizedData, originalError) {
    if (originalError.name === 'ValidationError') {
      var details = sanitizedData.details || {};
      sanitizedData.issueCount =  details.codes && Object.keys(details.codes).length;
    }
    return sanitizedData;
  }

bajtos avatar May 11 '16 13:05 bajtos