Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
27
lib/services/current_lesson_service.dart
Normal file
27
lib/services/current_lesson_service.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:initial_folder/base_service.dart';
|
||||
import 'package:initial_folder/helper/user_info.dart';
|
||||
import 'package:initial_folder/models/lesson_model.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CurrentLessonService {
|
||||
Future<LessonModel> getCurrentLesson(String lessonId) async {
|
||||
String? token = await UsersInfo().getToken();
|
||||
|
||||
print(
|
||||
"Ini Current Lesson ID ----------------------------------> : $lessonId");
|
||||
|
||||
Uri url = Uri.parse('$baseUrl/users/course/my/lesson/$lessonId');
|
||||
http.Response response =
|
||||
await http.get(url, headers: headerWithToken(token!));
|
||||
|
||||
print("Ini Current Lesson ------------------------> : ${response.body}");
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return LessonModel.fromJson(jsonDecode(response.body)["data"][0]);
|
||||
} else {
|
||||
throw Exception('Data Lesson Gagal Diambil');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user