Advertisement
Guest User

Untitled

a guest
Feb 27th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. var koa = require('koa');
  2. var router = require('koa-router');
  3. var app = koa();
  4. var thunkify = require('thunkify');
  5. app.use(router(app));
  6.  
  7. //Calback function
  8. function load(callback){
  9. result = 'Hello';
  10. //Do something with xmla4js and ajax
  11. callback(null, result);
  12. }
  13.  
  14.  
  15. load = thunkify(load);
  16.  
  17. function *loadJson(){
  18. var that = this;
  19. var result = yield load();
  20. that.status = 200;
  21. that.body = result;
  22. }
  23.  
  24. app.get('/load',loadJson);
  25.  
  26.  
  27. app.listen(3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement