Skip to content

Commit

Permalink
fix: dasboard fetch bug
Browse files Browse the repository at this point in the history
  • Loading branch information
angrezichatterbox committed Sep 24, 2024
1 parent f971e16 commit 8fa3dcf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/controllers/homepage/course_summary_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import 'package:bunk_mate/screens/OnBoardView.dart';
class CourseSummaryController extends GetxController {
var courseSummary = <CourseSummary>[].obs;
final storage = const FlutterSecureStorage();

var checkIn = false.obs;

Future<String?> getToken() async {
return await storage.read(key: 'token');
}
Expand All @@ -31,11 +30,9 @@ class CourseSummaryController extends GetxController {
var url = Uri.parse(
ApiEndPoints.baseUrl + ApiEndPoints.homeEndPoints.courseSummary);
http.Response response = await http.get(url, headers: headers);

print(response.statusCode);
if (response.statusCode == 200) {
final Map<String, String> responseMap = json.decode(response.body);
print(responseMap);
checkIn.value = true;
List<dynamic> jsonData = json.decode(response.body);
var fetchedSummary =
jsonData.map((data) => CourseSummary.fromJson(data)).toList();
Expand All @@ -45,8 +42,8 @@ class CourseSummaryController extends GetxController {
courseSummary.assignAll(fetchedSummary);
print("Task Done");
}
else {
Get.off(TimetableView());
else if (response.statusCode == 404) {
Get.offAll(TimetableView());
}
} catch (error) {
print(error);
Expand Down
1 change: 1 addition & 0 deletions lib/models/course_summary_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CourseSummary {
required this.bunksAvailable,
});


factory CourseSummary.fromJson(Map<String, dynamic> json) {
return CourseSummary(
name: json['name'],
Expand Down

0 comments on commit 8fa3dcf

Please sign in to comment.