I want to view all the URL's in my view, but I get #{data.id} Cannot read property 'id' of undefined error.
I want to create a loop and view all the videos I have.
app.js
app.get('/you', function(req,res) { youtube.where('id', '<', '5689').fetchAll().then(function(data) { res.render('youtube', { mi : data }); }); }); Here's an example output for a given ID (I changed res.render to res.send to test my query, so it works)
[ { "id": 442, "channel_name": "channelNameredacted", "video_url": "videoURlRedacted", "video_title": "redacted", "status": 1, "date": "redacted" } ] youtube.jade
Let's say I want to output video ID's.
html head body each data in mi #{data.id}
dataprovided byyoutubeincludes anundefinedelement in the collection –[ { id: 442 }, undefined ]. If you add the conditionif dataunder theeach, does it succeed then?#{...}at the start of a line renders a dynamically-named element –<442></442>. I'm guessing that's probably not what you were going for. To renderdata.idas text, add an element or a pipe before it –div #{data.id}or| #{data.id}.