Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - How to get stream into string

I have got stream and I need to get stream content into string. I stream from internet using http.get. I also write stream into file, but I don't want to write file and after that open the same file and read from it... So I need to convert stream into string Thanks for all advices...

like image 501
user2316602 Avatar asked Jul 02 '13 08:07

user2316602


1 Answers

var http = require('http');

var string = '';
var request = http.get("http://www.google.cz", function(response) {       
    response.on('data', function(response){
      string += response.toString();

  }); 
    response.on('end', function(string){
      console.log(string);
    });  
  });

This works for sure. I am using it.

like image 58
Sai Teja Avatar answered Sep 17 '22 20:09

Sai Teja