var fn_index = async (ctx, next) => {
let login = () => {
return new Promise((res, req) => {
setTimeout(()=>{
res(‘异步’)
},5000)
})
}
let res = await login()
console.log(res)
ctx.response.body = { mag: '账号或密码错误' }
}
module.exports = {
'/api/login': {
type: 'POST',
method: fn_index
}
}
```这个时候接口接收到的返回信息是404 notfond
去掉setTimeout的时候就是正常的
想要异步返回需要如何操作