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 _debug = isDebugEnabled(objectLevelDebug: debug);
  final ParseClient _client = 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(_client, keyEndPointUserName);
    final ParseNetworkResponse response = await _client.get(
      url.toString(),
      options: ParseNetworkOptions(headers: headers),
    );
    return await _handleResponse(
        this, response, ParseApiRQ.currentUser, _debug, parseClassName);
  } on Exception catch (e) {
    return handleException(e, ParseApiRQ.currentUser, _debug, parseClassName);
  }
}