Вы можете использовать:
const user = api.getCurrentUser() if(user) { return user.username; }
Подробнее здесь: