Skip to content

Instantly share code, notes, and snippets.

@RusAlex
Last active April 24, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RusAlex/d4a4c123f9081b8cf4660d29f725d644 to your computer and use it in GitHub Desktop.
Save RusAlex/d4a4c123f9081b8cf4660d29f725d644 to your computer and use it in GitHub Desktop.
/*eslint-env node */
var Koa = require('koa');
var fetch = require('node-fetch');
var app = new Koa();
app.use(function *() {
var that = this;
fetch('https://api.github.com/users/github')
.then(function(res) {
return res.json();
}).then(function(json) {
console.log(json);
that.status = 200;
that.body = json;
}).catch(function(err) {
console.log(err);
});
});
app.listen(8000, function (err) {
if (err) {
console.error(err); // eslint-disable-line no-console
process.exit(1);
}
process.stdout.write(`Listening at http://0.0.0.0:8000\n`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment