get method

Future<Response?> get(
  1. String apiPath
)

Executes a HTTP GET request for the given apiPath.

Applies:

  • Base URL resolution
  • Authorization headers
  • Timeout handling
  • Retry logic

Implementation

Future<Response?> get(String apiPath) async {
  Logger.log("--------> START OF GET API CALL <--------", type: LogType.api, tag: "DF-API-CLIENT");
  Uri apiUri = _generateApiUri(apiPath);
  return _processApiCall(
    apiPath: apiPath,
    httpApiConfig.maxRetryAttempts,
    apiCall: () async {
      return await httpClient
          .get(apiUri, headers: httpApiConfig.headers)
          .timeout(
            Duration(seconds: httpApiConfig.timeout),
            onTimeout: () => throw Exception("API Timeout exception, no response from the server for: $apiPath"),
          );
    },
  );
}