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
  • 19
  • 20
const Koa = require('koa');
var Router = require('koa-router')

const app = new Koa();

app
  .use((ctx,next) => {
    ctx.cookies.set('fruit', 'apple')
    ctx.body = 'hello'
    next()
  })
  .use((ctx,next) => {
    var cookie = ctx.cookies.get('fruit')
    console.log('Cookie in second middleware: ', cookie)
  });


app.listen(3000);