UNPKG

731 BJavaScriptView Raw
1var jpath = require('..')
2, http = require('http')
3, util = require('util')
4;
5
6var feed = "http://api.flickr.com/services/feeds/photos_public.gne?tags=beach,pipeline&tagmode=all&format=json&jsoncallback=processResponse"
7;
8
9function processResponse(json) {
10 var res = jpath.resolve(json, "#/items[first(3)]take(/title,/author,media=/media/m)")
11 console.log( util.inspect(res, false, 5) );
12}
13
14http.get(feed, function(res) {
15 console.log("Got response: " + res.statusCode);
16
17 var data = '';
18
19 res.on('data', function (chunk){
20 data += chunk;
21 });
22
23 res.on('end',function(){
24 // result is formatted as jsonp... this is for illustration only.
25 eval(data);
26 })
27}).on('error', function(e) {
28 console.log("Got error: " + e.message);
29});
\No newline at end of file