我正在制作一个使用 Vuejs 作为前端的网站。对于注册,我使用rest_auth.registration。
在 Vuejs 代码中,我通过 axios 发出注册 post 请求。
axios.post(this.registrationUrl,{
username,
email,
password1,
password2,
}).then(res => {
console.log('Registration Successful!')
}).catch(err => {
// console.log('There is error!')
let errData = err.response.data
this.errors.push(errData)
for (let errorType in errData) {
for (let error of errData[errorType]) {
this.errors.push(error)
}
}
})
Run Code Online (Sandbox Code Playgroud)
问题是,在注册用户时,即使注册成功并且可以在 django 管理面板中看到新用户,代码中的 Promise 也会返回错误。
返回错误:
OSError at /rest-auth/registration/ [Errno 99] Cannot assign requested address Request Method: POST Request URL: http://localhost:8000/rest-auth/registration/ Django Version: 1.11.8
Run Code Online (Sandbox Code Playgroud)