getRequest method

Future<Response> getRequest(
  1. String request,
  2. dynamic baseUrl,
  3. dynamic consumerKey,
  4. 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)}');
  }
}