getData method

Future<Response?> getData(
  1. String endpoint, {
  2. Map<String, dynamic>? headers,
  3. CancelToken? cancelToken,
})

Implementation

Future<Response?> getData(String endpoint,
    {Map<String, dynamic>? headers, CancelToken? cancelToken}) async {
  try {
    _dio.options.headers['content-Type'] = 'application/json';
    _dio.options.headers['authorization'] = _bearerToken;

    final response = await _dio.get(
      Uri.encodeFull(endpoint),
      options: Options(headers: headers),
      cancelToken: cancelToken,
    );
    return response;
  } on DioError catch (e) {
    throw handleException(e);
  } catch (e) {
    print("ERROR getData $e");
    throw Exception(e);
  }
}