Hello, I’ve recently started using Django and can’t say really anything against it!
So let’s get to my problem which I seriously don’t know how to solve.
I’m making a site with login, profile page, maybe some kind of wall. I successfully managed to get up and run django-restframework-simplejwt. Noice, so Authentication on my web has started working quite well!
But now I created a View for the current User to get his username and ID for profile page.
The code looks like this:
class CurrentUserView(View):
def get(self, request):
current_user = request.user
data = {
‘name’: request.user.username,
‘id’: request.user.id
}
return JsonResponse(data)
I then register the URL to urls.py as “my-api/”. All still works well. I can open localhost:8000/my-api and I get my “name” and “id”.
But then here comes the problem.
I’m using Nuxt so I don’t know if it has something to do with it. Nevermind, I’m logged in and I use Axios to GET the api response from my Django server, but the response simply comes empty as “name”: “”,
“id”: null
I’m currently running out of ideas of what might be wrong… I’d be more than grateful if someone was able to help me with that.