koa context request body code example

Example: how pass data from body in koa js

httpRouter.post('/syncCallJS/*', async (ctx, next) => {
 const idx = syncCallJSIndex++
 const channelId = ctx.params[0]
 const payload = ctx.request.body
 const device = Device.getDevice(channelId)
 if (device) {
  const terminal = new SyncTerminal()
  let data
  terminal.channelId = channelId
  syncV8Hub.join(terminal, false)
  payload.params.syncId = 100000 + idx
  payload.id = 100000 + idx
  data = await terminal.send(payload)
  ctx.response.status = 200
  ctx.type = 'application/json'
  ctx.response.body = JSON.stringify(data.ret)
 } else {
  ctx.response.status = 500
 }
 await next()
})