代码如下,这是一个登录页,
router.post('/login', function*(next) {
const body = this.request.body
const username = body.username
const password = body.password
const info = yield user.findOne({ username, password })
this.set('connection', 1111)
log(this.request.header)
log(this.response)
if (info && info.password === password) {
this.redirect('/home')
} else {
this.body = {
status: -1,
msg: '账号密码错误'
}
}
})
总是报错:
login:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0