getAuthenticatedUser method

Future<User?> getAuthenticatedUser(
  1. String token
)

Implementation

Future<User?> getAuthenticatedUser(String token) async {
  try {
    final result = await dio.get(
      '${Config.url}/users/single/me',
      options: Options(
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
          'Authorization': 'Bearer $token',
        },
      ),
    );

    return User.fromJson(result.data);
  } catch (e) {
    return null;
  }
}