Thursday 10 March 2016

Just starting express, how do I get my external api to display in a view?

I built an api with rails and have a huge headache after searching for this over the past few days. I can't seem to find a simple or straightforward solution on stackoverflow...In app.js I haveapp.get('/', function(req, res) { res.render('index', request(url, function(req, res, body) { res = JSON.parse(body) console.log(res.events[0]) } )) I'm able to print out my api response in the console, but can't seem to figure out how to get it in my view. I get 'Cannot read property 'length' of undefined' when I try `- each event in res'Anyone have an idea what I'm doing wrong?

Submitted March 10, 2016 at 09:23PM by imicit

No comments:

Post a Comment