get country api

This commit is contained in:
poojapandeyx
2024-07-10 17:34:49 +05:30
parent 0ab7bb6df0
commit 05e48ebbbe
15 changed files with 267 additions and 16 deletions

View File

@@ -6,37 +6,37 @@ class NetworkApiService {
final Dio _dio = Dio();
// Common function for GET requests
Future<Response> get(String endpoint,
Future<Response> get(String url,
{Map<String, dynamic>? queryParameters}) async {
try {
return await _dio.get(endpoint, queryParameters: queryParameters);
return await _dio.get(url);
} catch (e) {
throw _handleError(e);
}
}
// Common function for POST requests
Future<Response> post(String endpoint, dynamic data) async {
Future<Response> post(String url, dynamic data) async {
try {
return await _dio.post(endpoint, data: data);
return await _dio.post(url, data: data);
} catch (e) {
throw _handleError(e);
}
}
// Common function for PUT requests
Future<Response> put(String endpoint, dynamic data) async {
Future<Response> put(String url, dynamic data) async {
try {
return await _dio.put(endpoint, data: data);
return await _dio.put(url, data: data);
} catch (e) {
throw _handleError(e);
}
}
// Common function for DELETE requests
Future<Response> delete(String endpoint) async {
Future<Response> delete(String url) async {
try {
return await _dio.delete(endpoint);
return await _dio.delete(url);
} catch (e) {
throw _handleError(e);
}