headers property

  1. @override
Map<String, String> headers
override

The headers for any authenticated HTTP REST call to this CarpService.

Implementation

@override
Map<String, String> get headers {
  if (CarpAuthService().currentUser.token == null) {
    throw CarpServiceException(
        message:
            "OAuth token is null. Call 'CarpAuthService().authenticate()' first.");
  }

  return {
    "Content-Type": "application/json",
    "Authorization":
        "bearer ${CarpAuthService().currentUser.token!.accessToken}",
    "cache-control": "no-cache"
  };
}