ApiClient constructor

ApiClient()

Creates a new instance of ApiClient using the shared base URL and token.

Implementation

ApiClient() {
  dio = Dio(BaseOptions(
    baseUrl: _baseUrl.toString(),
    headers: {'Content-Type': 'application/json'},
  ));

  // Add interceptor to inject auth token on each request
  dio.interceptors.add(InterceptorsWrapper(
    onRequest: (options, handler) {
      if (_authToken != null) {
        options.headers['x-jwt-token'] = _authToken;
      }
      handler.next(options);
    },
  ));

  // Add cURL logger for debugging HTTP requests
  dio.interceptors.add(CurlLoggerDioInterceptor(printOnSuccess: true));
}