resolveBody static method

FutureOr<Object?> resolveBody(
  1. dynamic payload,
  2. APIResponse apiResponse
)

Resolves a payload to an HTTP body (accepts payload as a Future). See resolveBodySync.

Implementation

static FutureOr<Object?> resolveBody(
    dynamic payload, APIResponse apiResponse) {
  if (payload == null) return null;

  if (payload is Future) {
    return payload.then((value) {
      return resolveBody(value, apiResponse);
    }, onError: (e, s) {
      return apiResponse.asError(error: 'ERROR: $e\n$s');
    });
  }

  return _resolveBodyImpl(payload, apiResponse);
}