call<T> method

FutureOr<APIResponse<T>> call<T>(
  1. APIRequest request, {
  2. bool externalCall = false,
})

Calls the API.

Implementation

FutureOr<APIResponse<T>> call<T>(APIRequest request,
    {bool externalCall = false}) {
  if (request.method == APIRequestMethod.OPTIONS) {
    throw ArgumentError("Can't perform a call with an `OPTIONS` method. "
        "Requests with method `OPTIONS` are reserved for CORS or other informational requests.");
  }

  var modulesLoadAsync = _ensureModulesLoaded();

  if (modulesLoadAsync is Future<InitializationResult>) {
    return modulesLoadAsync.then((_) => _callZoned<T>(request, externalCall));
  } else {
    return _callZoned<T>(request, externalCall);
  }
}