bodyAsObject property

Object? bodyAsObject

Returns the parsed request body, whatever it may be (typically a Map or List).

Note that parseBody must be called first.

Implementation

Object? get bodyAsObject {
  if (!hasParsedBody) {
    throw StateError('The request body has not been parsed yet.');
  }

  return _bodyObject;
}
void bodyAsObject=(dynamic value)

This setter allows you to explicitly set the request body exactly once.

Use this if the format of the body is not natively parsed by Angel.

Implementation

set bodyAsObject(value) {
  if (_bodyObject != null) {
    throw StateError(
        'The request body has already been parsed/set, and cannot be overwritten.');
  } else {
    if (value is List) _bodyList = value;
    if (value is Map<String, dynamic>) _bodyFields = value;
    _bodyObject = value;
    _hasParsedBody = true;
  }
}