After adding dj-rest-auth I get a sever error 500
After adding user authentication I have not been able to get data from my MySQL database, I get an error code 500 and Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0. I think it might be something to do with my requests and after user authentication I need to add a token to make requests but I am unsure how to. I followed this tutorial: https://blog.devgenius.io/django-react-authentication-part-1-d351726b284d. Exact code can be found here as well as before and after. https://github.com/DoritoThePug/ToDoList/tree/bug%231
All of the 3rd party frameworks
'rest_framework',
'rest_framework.authtoken',
'dj_rest_auth',
'allauth',
'allauth.account',
'allauth.socialaccount',
'dj_rest_auth.registration',
'corsheaders'
Custom User
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class CustomUser(AbstractUser):
def __str(self):
return self.email
Fetch Request
fetch("/api")
.then(response => response.json())
.then(
data =>
this.setState({
todoList: data
})
)
As I said, this worked perfectly before I followed the tutorial and added user authentication, I can make requests to the database for user authentication register/logout/login perfectly just not get data from my api. More specific code can be found at the github link above.