getChapters method
Implementation
Future<String> getChapters(String slug) async {
try {
final response = await _dio.get('/$slug');
final document = html.parse(response.data.toString());
final anchors = document.querySelectorAll('div.media-chapter');
List res = [];
for (final ch in anchors) {
res.add(ch);
}
return response.data.toString();
} on DioException catch (e) {
if (e.response!.statusCode == 400) {
throw Exception("Bad slug! Media not found!");
} else {
throw Exception("An error has occurred");
}
}
}