Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

可能不需要await next? #4

Open
simon300000 opened this issue Oct 31, 2019 · 1 comment
Open

可能不需要await next? #4

simon300000 opened this issue Oct 31, 2019 · 1 comment

Comments

@simon300000
Copy link
Member

simon300000 commented Oct 31, 2019

ctx.response.status = 500
ctx.response.body = 'Internal Server Error: ' + JSON.stringify(e)
await next()

ctx.response.status = 500
ctx.response.body = 'Internal Server Error: ' + JSON.stringify(e)
await next()

sc.get('/', async (ctx, next) => {
ctx.response.status = 404
ctx.response.body = 'Simon Not Found'
await next()
})
// /sc/getData
sc.post('/getData', async (ctx, next) => {
if (!global.amdb) {
ctx.response.status = 500
ctx.response.body = 'Internal Server Error: AMDB ERR'
await next()
return
}
if (!global.predb) {
ctx.response.status = 500
ctx.response.body = 'Internal Server Error: PreDB ERR'
await next()
return
}
const amdb = global.amdb
const predb = global.predb
if (!ctx.request.body.roomid || isNaN(Number(ctx.request.body.roomid))) {
ctx.response.status = 404
ctx.response.body = 'Bad Request Format'
await next()
} else {

sc.post('/', async (ctx, next) => {
ctx.response.status = 404
ctx.response.body = 'Page Not Found'
await next()
})

sc.post('/', async (ctx, next) => {
ctx.response.status = 404
ctx.response.body = 'Page Not Found'
await next()
})

@simon300000 simon300000 changed the title 都Bad Request Format为什么还要await 都Bad Request Format为什么还要await next Oct 31, 2019
@simon300000 simon300000 changed the title 都Bad Request Format为什么还要await next 可能不需要await next? Oct 31, 2019
@ilharp
Copy link
Collaborator

ilharp commented Nov 1, 2019

之后有时间的话会进行修改。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants