I have a web app with React frontend and Django rest API backend. when I enter the correct username and password to log in I get the message that should appear when the username or password is wrong.
The React code:
fetch('/token-auth/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({username: this.state.username, password: this.state.password})
})
.then(res => res.json())
.then(json => {
if (json.ok) {
localStorage.setItem('token', json.token);
this.props.notify_login(this.state.username)
}
else {
this.setState({been_failed: true})
}
});
So as you can understand the code enters the else block. But the Django server prints the following message saying that the response code is 200.
"POST /token-auth/ HTTP/1.1" 200 286
Does anyone know what can cause such a thing?