summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--routes/index.js12
-rw-r--r--views/data.jade7
2 files changed, 16 insertions, 3 deletions
diff --git a/routes/index.js b/routes/index.js
index 1edd536..7ae3aa0 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -115,10 +115,17 @@ exports.write = function(req, res) {
var body = {template: { data: data }};
// console.log('body', JSON.stringify(body));
function done(message, httpResponse) {
+ var parsedBody;
+ try {
+ parsedBody = JSON.parse(httpResponse.body);
+ } catch(e) {}
res.render('data', {
urlgenerator: urlgenerator(req),
url: req.body.url,
- httpResponse: httpResponse
+ root: collection_json.fromObject(parsedBody),
+ httpResponse: httpResponse,
+ parsedBody: parsedBody,
+ rawBody: httpResponse.body
});
}
var httpRequest = http.request(options, function(httpResponse) {
@@ -163,7 +170,8 @@ exports.render = function(req, res) {
params: params,
root: collection_json.fromObject(parsedBody),
httpResponse: httpResponse,
- formattedBody: JSON.stringify(parsedBody, null, ' ')
+ parsedBody: parsedBody,
+ rawBody: httpResponse.body
});
});
};
diff --git a/views/data.jade b/views/data.jade
index c757498..3d844a3 100644
--- a/views/data.jade
+++ b/views/data.jade
@@ -349,7 +349,12 @@ block inner_content
h1 Formatted Body
div(class='row-fluid')
div(class='span12')
- pre= formattedBody
+ if typeof rawBody == 'string'
+ if rawBody.length == 0
+ p: i No body
+ else
+ pre= JSON.stringify(parsedBody, null, ' ')
+ | #{parsedBody}
if typeof httpResponse != 'undefined'
section(id='http-response')