[Answered ]-Getting custom Django REST user class in React using JSON Web Token

1👍

'user': str(request.user) this would fetch the user object and call __str__ method

@api_view(['GET'])
@authentication_classes([JWTAuthentication])
def GetUser(request, format=None):
    user = request.user
    content = {
        'id': user.id,
        'email': user.email,
        'first_name': user.first_name,
        # other_fields
        'auth': str(request.auth)
    }
    return Response(content)

Leave a comment