From 291803c31f829fe0d32bb3207bc11def95a7408c Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 20:05:50 +0100 Subject: Urađena test aplikacija. Povezan front i back. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node_modules/jsonparse/examples/twitterfeed.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sandbox/testAppNevena/Front/node_modules/jsonparse/examples/twitterfeed.js (limited to 'sandbox/testAppNevena/Front/node_modules/jsonparse/examples/twitterfeed.js') diff --git a/sandbox/testAppNevena/Front/node_modules/jsonparse/examples/twitterfeed.js b/sandbox/testAppNevena/Front/node_modules/jsonparse/examples/twitterfeed.js new file mode 100644 index 00000000..10210d47 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/jsonparse/examples/twitterfeed.js @@ -0,0 +1,30 @@ +var Parser = require('../jsonparse'); +var Http = require('http'); +require('./colors'); +var p = new Parser(); +var cred = require('./credentials'); +var client = Http.createClient(80, "stream.twitter.com"); +var request = client.request("GET", "/1/statuses/sample.json", { + "Host": "stream.twitter.com", + "Authorization": (new Buffer(cred.username + ":" + cred.password)).toString("base64") +}); +request.on('response', function (response) { + console.log(response.statusCode); + console.dir(response.headers); + response.on('data', function (chunk) { + p.write(chunk); + }); + response.on('end', function () { + console.log("END"); + }); +}); +request.end(); +var text = "", name = ""; +p.onValue = function (value) { + if (this.stack.length === 1 && this.key === 'text') { text = value; } + if (this.stack.length === 2 && this.key === 'name' && this.stack[1].key === 'user') { name = value; } + if (this.stack.length === 0) { + console.log(text.blue + " - " + name.yellow); + text = name = ""; + } +}; -- cgit v1.2.3