1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 16:13:18 +00:00
musix-oss/node_modules/needle/examples/parsed-stream.js
2020-03-04 13:43:21 +02:00

24 lines
535 B
JavaScript

//////////////////////////////////////////
// This example demonstrates what happends
// when you use the built-in JSON parser.
//////////////////////////////////////////
var fs = require('fs'),
stream = require('stream'),
needle = require('./../');
var url = 'http://ip.jsontest.com/',
resp = needle.get(url, { parse: true });
resp.on('readable', function(obj) {
var chunk;
while (chunk = this.read()) {
console.log('root = ', chunk);
}
});
resp.on('done', function() {
console.log('Done.');
});