Advertisement
Guest User

Untitled

a guest
May 5th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Create a koa server which parse the post data, Convert the name field to
  2. upper case and respond to client.
  3.  
  4. If you get this:
  5.  
  6. POST / with { name: 'koa' }
  7.  
  8. Respond with:
  9.  
  10. KOA
  11.  
  12.  
  13. I have this solution but this does not work :
  14.  
  15. var koa = require('koa');
  16. var bodyParser = require('koa-bodyparser');
  17.  
  18. var app = koa();
  19.  
  20. app.use(bodyParser({
  21. detectJSON: function (ctx) {
  22. this.body = ctx.toUpperCase();
  23. }
  24. }));
  25.  
  26. app.listen(process.argv[2]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement