bodyTo<T> method
Converts the body to typ T
.
Implementation
Future<T> bodyTo<T>(Converter<T, dynamic> converter,
{conv.Encoding encoding = conv.utf8}) async {
MimeType mt = mimeType;
Map? b;
if (mt.isJson) {
b = await bodyAsJsonMap(encoding: encoding);
} else if (mt.isUrlEncodedForm) {
b = await bodyAsUrlEncodedForm();
} else if (mt.isFormData) {
b = await _formDataMapToStringMap(await bodyAsFormData());
}
// TODO use serializer for other mimetypes
return converter(b);
}