Last active
April 24, 2016 12:47
-
-
Save RusAlex/d4a4c123f9081b8cf4660d29f725d644 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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