getRequest method
Future<Response>
getRequest(
- String request,
- dynamic baseUrl,
- dynamic consumerKey,
- dynamic consumerSecret,
Implementation
Future<http.Response> getRequest(
String request, baseUrl, consumerKey, consumerSecret) async {
final response = await http.get(
Uri.parse(baseUrl! + request),
// Add your authentication headers here
headers: {
'Authorization':
'Basic ${base64Encode(utf8.encode('$consumerKey:$consumerSecret'))}',
},
);
if (response.statusCode == 200) {
return response;
} else {
throw Exception(
'Error -: Failed to Complete Request : ${json.decode(response.body)}');
}
}