mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 16:04:56 +00:00
api
This commit is contained in:
24
node_modules/needle/examples/parsed-stream.js
generated
vendored
Normal file
24
node_modules/needle/examples/parsed-stream.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
//////////////////////////////////////////
|
||||
// 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('end', function(data) {
|
||||
console.log('Done.');
|
||||
});
|
||||
|
Reference in New Issue
Block a user