import 'package:dio/dio.dart'; class KycService { Future> getKycData(String token) async { try { var response = await Dio().get( 'https://api.cnapp.co.in/api/kyc/getAll', options: Options( headers: { 'Authorization': 'Bearer $token', }, ), ); if (response.statusCode == 200) { print("response of /api/kyc/getAll : ${response.data}"); return response.data; // Return the data as a List } else { throw Exception("Failed to load KYC data"); } } catch (e) { print("Error fetching KYC data: $e"); return []; } } } // import 'dart:convert'; // import 'package:cheminova/utils/api_urls.dart'; // import '../models/kyc_model.dart'; // import '../utils/common_api_service.dart'; // // class KycService { // Future?> getKycData(String token) async { // String url = ApiUrls.getKyc; // API endpoint for KYC data // // // Use the commonApiService for making the API request // final response = await commonApiService>( // method: "GET", // url: url, // additionalHeaders: { // 'Authorization': 'Bearer $token', // Add the token in headers // }, // fromJson: (json) // { // if (json != null && json['data'] != null) { // List dataList = json['data']; // Access 'data' array // return dataList.map((item) => KycModel.fromJson(item)).toList(); // } else { // print('Invalid KYC response or data is null'); // return []; // } // // // // }, // ); // // // Return the parsed KYC data list, or an empty list in case of failure // return response; // } // }