get method

Future<Response> get(
  1. dynamic url, {
  2. Map<String, String>? headers,
})

Implementation

Future<Response> get(url, {Map<String, String>? headers}) async {
  try {
    final response = await http.get(url, headers: headers);
    if (response.statusCode == 401) {
      if (json.decode(response.body)['message'] == 'Expired JWT Token') {
        throw ExpiredTokenException(response.reasonPhrase);
      } else {
        throw AuthenticateException(response.reasonPhrase);
      }
    } else {
      return response;
    }
  } catch (e) {
    return http.Response(e.toString(), 500);
  }
}