resolveResponse method
Method responsible to resolve the response
to a R
value.
Can be overwritten by other implementations.
Implementation
R? resolveResponse(HttpResponse? response) {
if (response == null) {
return null;
} else if (!response.isOK) {
throw StateError(
"Can't perform request. Response{ status: ${response.status} ; body: ${response.bodyAsString}} > $this");
} else if (response.isBodyTypeJSON) {
return response.json as R?;
} else {
return response.bodyAsString as R?;
}
}