title: Trying to use koa bodyparser and ctx.body undefined
body: <p>I'm trying to learn koa and can't figure out why i'm getting the error:</p>
  
  <pre><code>server error TypeError: ctx.body is not a function
      at getHandler (/Users/tomcaflisch/Sites/learn-koa/server.js:32:7)
  </code></pre>
  
  <p>when I run this code:</p>
  
  <pre class="lang-js prettyprint-override"><code>'use strict'
  
  const Router = require('koa-router')
  const bodyParser = require('koa-bodyparser')
  
  function server (app) {
    const router = new Router()
    router.get('/foo', getHandler)
    app.use(bodyParser())
    app.use(router.routes())
  
  
    app.use(async (ctx, next) =&gt; {
      try {
        await next();
      } catch (err) {
        ctx.status = err.status || 500;
        ctx.body = err.message;
        ctx.app.emit('error', err, ctx);
      }
    });
  
    app.on('error', (err, ctx) =&gt; {
      console.log('server error', err, ctx)
    });
  
    app.listen(4000)
  }
  
  function getHandler (ctx, next) {
    // ctx.set('Location', 'http://localhost:3000/foo')
    ctx.body({ foo: 'bar' })
  }
  
  module.exports = server
  </code></pre>