Fri Jan 27 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
router.get('/', home)

app.use((ctx, next) => {
  console.log('1st middleware. Setting cookie to "blue"')
  ctx.cookies.set('color', 'blue')
  next()
})

app.use(router.routes())

function home(ctx, next) {
  var cookie = ctx.cookies.get('color')
  console.log('Inside /home handler. Cookie: ', cookie)
  // cookie is undefined
}


app.listen(3000);