Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET user API is not working #1

Open
amithpdn opened this issue Jul 30, 2020 · 1 comment
Open

GET user API is not working #1

amithpdn opened this issue Jul 30, 2020 · 1 comment

Comments

@amithpdn
Copy link

amithpdn commented Jul 30, 2020

GET user API returns an empty response.

{
    "name": "",
    "email": "",
    "username": ""
}

This seems to be caused by missing return statements in the UserAPI class. However return Response (self.request.user) returns an error too.
When return self.request.user return id, name, email, username

class UserAPI(generics.RetrieveAPIView):
	permission_classes = [
		permissions.IsAuthenticated
	]
	serializer_class = UserSerializer

	def get_object(self):
		self.request.user
@jayaike
Copy link
Owner

jayaike commented Jul 30, 2020

Hi @amithpdn,

I believe there is an indentation error on your get_object method

def get_object(self):
    return self.request.user

You shouldn't return a Response in the get_object method. What you want to return is a model instance which is self.request.user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants