Commit e55d31ba authored by Ilham Maulana's avatar Ilham Maulana 💻

fix: fetch new categories endpoint

parent 1ba1afc1
......@@ -60,6 +60,7 @@ class BookProvider with ChangeNotifier {
Future<void> getCategories() async {
try {
setLoading(true);
final response = await http.get(
Uri.parse('$baseUrl/categories'),
headers: {'Content-Type': 'application/json'},
......@@ -67,11 +68,12 @@ class BookProvider with ChangeNotifier {
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
categories = data["results"];
categories = data;
} else {
debugPrint("Error: Fetch books failed, ${response.statusCode}");
}
setLoading(false);
notifyListeners();
} catch (error) {
debugPrint("Error: Fetch books failed, $error");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment