File: samples/http-get-request.js

Recommend this page to a friend!
  Classes of Igor Escobar   Terminal Crossword   samples/http-get-request.js   Download  
File: samples/http-get-request.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Terminal Crossword
Generate a crosswords board on a text console
Author: By
Last change:
Date: 2 years ago
Size: 479 bytes
 

Contents

Class file image Download
var http = require('http'); var options = { host: 'www.google.com', port: 80, path: '/', method: 'GET' }; var req = http.request(options, function(res) { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); }); }); req.on('error', function(e) { console.log('problem with request: ' + e.message); }); req.end();