getWithIntercept function
Future
getWithIntercept(
- String endpoint, {
- Duration timeoutDuration = const Duration(seconds: 60),
})
Implementation
Future<dynamic> getWithIntercept(String endpoint,
{Map<String, String>? headers,
Duration timeoutDuration = const Duration(seconds: 60)}) async {
await initBinoxusPayEnvs();
final baseUrl = binoxusPayEnvSingleton.baseUrl;
final url = Uri.parse("$baseUrl$endpoint");
// debugPrint('formated get url : $url');
try {
final response = await httpClient.get(url, headers: headers);
// debugPrint('response : ${response.body}');
if (response.statusCode == 200 || response.statusCode == 201) {
return jsonDecode(response.body);
} else {
throw Exception('Error : ${response.statusCode}');
}
} on HttpException catch (e) {
throw Exception('Request failed: ${e.message}');
}
}