我有一个带有react和Django rest框架的应用程序。我使用Django allauth进行登录和注册。当我要登录时,一切正常,响应为201,但数据为空,我没有获得令牌。我与邮递员发送了此请求,并获得了令牌。我该怎么办?
反应请求:
axios({
method: 'post',
url: 'http://localhost:8000/rest-auth/login/',
data: {
username: 'admin',
email: '',
password: 'admin123456'
},
headers: { 'content-type': 'application/json' }
})
.then(response => {
console.log(response.data.key);
})
.catch(error => {
console.log(error);
});
响应为:
{data: "", status: 200, statusText: "OK", headers: {…}, config: {…}, …}
邮递员请求:http://localhost:8000/rest-auth/login/
{
"username": "mahtab",
"email": "",
"password": "mahtab23"
}
邮递员回应:
{
"key": "f75b9f54848a94ac04f455321118aff5d5a7e6f8"
}