I've managed to make a GET request to an API however now I want to get the response on to a Jade page. Here is my code for the GET request so far. This is in 'index.js' in the routes 'folder'. Any ideas about how I can get the response on to a Jade page?
router.get('/', function(req, res) {
var url = 'http://data.police.uk/api/forces';
http.get(url, function(res){
var body = '';
res.on('data', function(chunk){
body += chunk;
});
res.on('end', function(){
var response = JSON.parse(body)
console.log("Successful")
});
}).on('error', function(e){
console.log("Error: ", e);
})
});
module.exports = router;
In your router
res.render('viewName',{"variable":"value"});
In your view
p #{variable}
Instead of trying to start from scratch, you should probably look at some sample templates for node.js with express.
http://blog.ijasoneverett.com/2013/03/a-sample-app-with-node-js-express-and-mongodb-part-1/
This would tell you how to set up the structure of the app.