getRequest static method

Future<Response> getRequest({
  1. required String endpoint,
  2. String? key,
})

Implementation

static Future<Response> getRequest(
    {required String endpoint, String? key}) async {
  late var headerWithToken;
  if (key != null) {
    headerWithToken = {
      "Content-Type": "application/json",
      "x-growlytics-key": "${key}"
    };
  }
  Uri uri = Uri.parse(Endpoints.baseUrl2 + endpoint);
  Response response =
      await get(uri, headers: (key != null) ? headerWithToken : _header)
          .timeout(
              Duration(
                seconds: 30,
              ), onTimeout: () {
    return Response("Time Out", 408);
  });

  return response;
}