watwatwat

Untitled

Oct 25th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const http = require('http');
  2.  
  3. const request = http.get('some url', (response) => {
  4.     let body = "";
  5.  
  6.     response.on('data', (chunk) => {
  7.       body += chunk;
  8.     });
  9.  
  10.  
  11.     response.on('end', () => {
  12.       if(response.statusCode === 200){
  13.         try {
  14.           console.log(body);
  15.         } catch(e) {
  16.           console.log('Error!');
  17.         }
  18.       }
  19.     });
  20.   });
Add Comment
Please, Sign In to add comment