getUser method

Future<GotrueUserResponse> getUser(
  1. String jwt
)

Gets the user details.

Implementation

Future<GotrueUserResponse> getUser(String jwt) async {
  try {
    final headers = {...this.headers};
    headers['Authorization'] = 'Bearer $jwt';
    final options = FetchOptions(headers);
    final response = await _fetch.get('$url/user', options: options);
    if (response.error != null) {
      return GotrueUserResponse.fromResponse(response: response);
    } else {
      final user = User.fromJson(response.rawData as Map<String, dynamic>);
      return GotrueUserResponse.fromResponse(response: response, user: user);
    }
  } catch (e) {
    return GotrueUserResponse(error: GotrueError(e.toString()));
  }
}