getUpdatedUser method

Future<ParseResponse> getUpdatedUser({
  1. bool? debug,
  2. ParseClient? client,
})

Get the updated version of the user from the server

Uses token to get the latest version of the user. Prefer this to getCurrentUserFromServer if using custom ParseUser object

Implementation

Future<ParseResponse> getUpdatedUser(
    {bool? debug, ParseClient? client}) async {
  final bool debugLocal = isDebugEnabled(objectLevelDebug: debug);
  final ParseClient clientLocal = client ??
      ParseCoreData().clientCreator(
          sendSessionId: true,
          securityContext: ParseCoreData().securityContext);

  // We can't get the current user and session without a sessionId
  if ((ParseCoreData().sessionId == null) && (sessionToken == null)) {
    ///return null;
    throw 'can not get the current user and session without a sessionId';
  }

  final Map<String, String> headers = <String, String>{};
  if (sessionToken != null) {
    headers[keyHeaderSessionToken] = sessionToken!;
  }

  try {
    final Uri url = getSanitisedUri(clientLocal, keyEndPointUserName);
    final ParseNetworkResponse response = await clientLocal.get(
      url.toString(),
      options: ParseNetworkOptions(headers: headers),
    );
    return await _handleResponse(
        this, response, ParseApiRQ.currentUser, debugLocal, parseClassName);
  } on Exception catch (e) {
    return handleException(
        e, ParseApiRQ.currentUser, debugLocal, parseClassName);
  }
}