parseCallableResponse method

Future parseCallableResponse(
  1. Response response
)

Parses the result field from a successful callable Response body.

Throws FormatException if the body is not valid JSON or does not contain a result key.

Implementation

Future<dynamic> parseCallableResponse(Response response) async {
  final body = await response.readAsString();
  final decoded = jsonDecode(body);
  if (decoded is! Map<String, dynamic>) {
    throw FormatException('Response body is not a JSON object: $body');
  }
  return decoded['result'];
}