pd-android-app/lib/controller/kyc_service.dart

34 lines
936 B
Dart

import 'package:cheminova/utils/api_urls.dart';
import 'package:dio/dio.dart';
class KycService {
// Function to fetch KYC data from the API
Future<List<dynamic>> getKycData(String token) async {
try {
// Make a GET request to the KYC API endpoint with authorization token
var response = await Dio().get(
ApiUrls.getKycUrl,
// 'https://api.cnapp.co.in/api/kyc/getAll',
options: Options(
headers: {
'Authorization': 'Bearer $token',
},
),
);
// Check if the response status code indicates success
if (response.statusCode == 200) {
print("response of ApiUrls.getKycUrl: ${response.data}");
return response.data; // Return the data as a List<dynamic>
} else {
throw Exception("Failed to load KYC data");
}
} catch (e) {
print("Error fetching KYC data: $e");
return [];
}
}
}