Merge pull request #680 from PlasmaPower/readme-semicolons

Added semicolons to README v2 alpha example
This commit is contained in:
Yiyu He 2016-03-14 23:15:43 +08:00
commit 66f7c35ee1

View file

@ -26,22 +26,22 @@ $ npm install koa
```js ```js
// Koa application is now a class and requires the new operator. // Koa application is now a class and requires the new operator.
const app = new Koa() const app = new Koa();
// uses async arrow functions // uses async arrow functions
app.use(async (ctx, next) => { app.use(async (ctx, next) => {
try { try {
await next() // next is now a function await next(); // next is now a function
} catch (err) { } catch (err) {
ctx.body = { message: err.message } ctx.body = { message: err.message };
ctx.status = err.status || 500 ctx.status = err.status || 500;
} }
}) });
app.use(async ctx => { app.use(async ctx => {
const user = await User.getById(ctx.session.userid) // await instead of yield const user = await User.getById(ctx.session.userid); // await instead of yield
ctx.body = user // ctx instead of this ctx.body = user; // ctx instead of this
}) });
``` ```
To learn more about Koa v2, follow [this issue](https://github.com/koajs/koa/issues/533). To learn more about Koa v2, follow [this issue](https://github.com/koajs/koa/issues/533).
To try Koa v2, `npm install koa@next`. To try Koa v2, `npm install koa@next`.