summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-06-29 09:27:22 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-06-29 09:27:22 +0200
commitc04cb305f45e39b71a7bdd51f91e8076eae86481 (patch)
tree9a1351ea2092d5863698519e138a76aad658f5e4 /routes
parente81f24cc6e2de2ed314a1c912c4cb4853b4c13fe (diff)
downloadcollection-json-explorer-c04cb305f45e39b71a7bdd51f91e8076eae86481.tar.gz
collection-json-explorer-c04cb305f45e39b71a7bdd51f91e8076eae86481.tar.bz2
collection-json-explorer-c04cb305f45e39b71a7bdd51f91e8076eae86481.tar.xz
collection-json-explorer-c04cb305f45e39b71a7bdd51f91e8076eae86481.zip
o Showing doc.uri and doc.version.
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/routes/index.js b/routes/index.js
index 6910dfa..1a05e39 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -13,21 +13,20 @@ exports.render = function(req, res){
accept: 'application/vnd.collection+json'
};
var clientReq = http.request(options, function(clientRes) {
- console.log('STATUS: ' + clientRes.statusCode);
- console.log('HEADERS: ' + JSON.stringify(clientRes.headers));
clientRes.setEncoding('utf8');
- var body = "";
+ var body = '';
clientRes.on('data', function (chunk) {
body += chunk;
});
clientRes.on('end', function (chunk) {
- var doc = collection_json.fromObject(JSON.parse(body));
+ var parsedBody = JSON.parse(body);
+ var doc = collection_json.fromObject(parsedBody);
res.render('data', {
url: req.query.url,
doc: doc,
headers: clientRes.headers,
raw: body,
- formattedRaw: JSON.stringify(JSON.parse(body), null, ' ') });
+ formattedRaw: JSON.stringify(parsedBody, null, ' ') });
});
});
clientReq.on('error', function() {