handleResponseWithBody method
String
handleResponseWithBody(
- Response response
)
Implementation
String handleResponseWithBody(http.Response response) {
final responseBody = utf8.decode(response.bodyBytes);
if (response.statusCode >= 400) {
final jsonMap = json.decode(responseBody);
final error = SpotifyError.fromJson(jsonMap['error']);
if (response.statusCode == 429) {
throw ApiRateException.fromSpotify(
error, num.parse(response.headers['retry-after']!));
}
throw SpotifyException.fromSpotify(
error,
);
}
return responseBody;
}