Guest User

Untitled

a guest
Apr 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. 'use strict';
  2.  
  3. /**
  4. * $ nvm use 8
  5. * $ npm i koa request
  6. */
  7.  
  8. const Koa = require('koa');
  9. const app = new Koa();
  10.  
  11. const request = require('request');
  12. const DOC_URL = process.argv[2];
  13.  
  14. app.use(async ctx => {
  15. ctx.body =
  16. request.get(DOC_URL)
  17. .on('response', function(response) {
  18. console.log('statusCode:', response.statusCode);
  19. console.log('content-type:', response.headers['content-type']);
  20. });
  21. });
  22.  
  23. app.listen(3001, () => {
  24. console.log('listening ...');
  25. });
Add Comment
Please, Sign In to add comment