28 lines
898 B
Dart
28 lines
898 B
Dart
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');
|
|
}
|
|
}
|
|
}
|