Skip to content

Instantly share code, notes, and snippets.

@spasiu
Created November 4, 2015 02:21
Show Gist options
  • Save spasiu/46f45da00fc4c102b341 to your computer and use it in GitHub Desktop.
Save spasiu/46f45da00fc4c102b341 to your computer and use it in GitHub Desktop.

you know how to use Express middleware

app.get(‘/‘, function(req, res) {
  var someVar1;
  promisesomeshit()
    .then(function(someshit){
      someVar1 = someshit;
      return promiseSomeOtherShit();  
    })
    .then(function(otherShit){
      res.status(200).send(otherShit + someVar1)
    });
});

well in Koa you write that shit out:

app.get(‘/‘, function* () {
  let someshit = yield promisesomeshit();
  let someMoreShit = yield promiseSomeOtherShit();
  this.body = someshit + someMoreShit;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment