Controller

mail@pastecode.io avatar
unknown
dart
2 years ago
1.1 kB
7
Indexable
Never
class DetailProfilController extends GetxController {
  var listProfil = List<Data>.empty(growable: true).obs;

  // RxList<Data> get listProfilData => listProfil.toList().obs;


  Dio dio = Dio();
  String getNim = ProfileUtils.readProfile().numberid;

  @override
  void onInit() async {
    super.onInit();
  }

  Future<List<Data>> getDetailProfil() async {
    try {
      final response = await dio.getUri(
          Uri.https(
            url_dev,
            '/career/get/6706194038',
          ),
          options: d.Options(headers: {
            'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
            'Authorization': 'Basic bXl0ZWx1Ok4wdGhpbmdfczNjdXJl'
          }));
      if (response.statusCode == 200) {
        print('get profil success');
        var jsonResponse =
            detailProfileModelFromJson(jsonEncode(response.data));
        listProfil.add(jsonResponse.data);
        print(listProfil);
      }
    } catch (e) {
      print('gagal');
      debugPrint(e.toString());
    }
    return listProfil;
  }