source: trip-planner-front/node_modules/needle/examples/parsed-stream.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 535 bytes
Line 
1//////////////////////////////////////////
2// This example demonstrates what happends
3// when you use the built-in JSON parser.
4//////////////////////////////////////////
5
6var fs = require('fs'),
7 stream = require('stream'),
8 needle = require('./../');
9
10var url = 'http://ip.jsontest.com/',
11 resp = needle.get(url, { parse: true });
12
13resp.on('readable', function(obj) {
14 var chunk;
15
16 while (chunk = this.read()) {
17 console.log('root = ', chunk);
18 }
19});
20
21resp.on('done', function() {
22 console.log('Done.');
23});
Note: See TracBrowser for help on using the repository browser.