getBytes method

Future getBytes({
  1. String? baseUrl,
  2. String? authorization,
  3. required String path,
  4. bool skipJsonDecode = false,
})

Implementation

Future getBytes({
  String? baseUrl,
  String? authorization,
  required String path,
  bool skipJsonDecode = false,
}) async {
  http_package.Response? response;
  try {
    baseUrl ??= Api.getAPIBaseUrls();
    final url = Uri.parse(baseUrl + path);
    log('GET---$url');

    response = await http_package.get(
      url,
      headers: header(authorization),
    );
    log('Status Code:${response.statusCode}');
    log('Response : ${response.body}');
    log('isFailure : ${isFailure(response.statusCode)}');
    if (skipJsonDecode || isFailure(response.statusCode)) {
      return response.body;
    }
    return json.decode(response.body);
  } catch (exception) {
    log(exception);

    return null;
  }
}