Reputation: 791
I have a jade template that should list all possible solutions to the QPX Express search request:
{ kind: 'qpxExpress#tripsSearch',
trips:
{ kind: 'qpxexpress#tripOptions',
requestId: 'RwDOf6HXVDvvn6nBm0PNpw',
data:
{ kind: 'qpxexpress#data',
airport: [Object],
city: [Object],
aircraft: [Object],
tax: [Object],
carrier: [Object] },
tripOption: [ [Object], [Object], [Object] ] } }
However, I'm trying to render the above the view but I keep getting this error:
Cannot read property 'tripOption' of undefined
Template
block content
.ui
for data in result
.ui_box
.ui_box__inner
.event
span #{data.trips.tripOption[].saleTotal}
Route
router.get('/', function(req, res, next) {
api.apiGet(function (data) {
console.log(data) //THIS WORKS
res.render('index', {result: data})
})
})
All the code is looking right to me and I'm working off properties from the API documentation. Can anyone point me in the right direction to debug?
Upvotes: 0
Views: 62
Reputation: 5226
Update: 1
To display saleTotal
from array of tripOption
, change your jade template like the below one,
block content
.ui
for data in result
.ui_box
.ui_box__inner
.event
each trip in data.trips.tripOption
span #{trip.saleTotal}
In your code, span #{data.trips.tripOption[].saleTotal}
if data
refers to JSON content then change your span bindings like this
span #{data.trips.data.tripOption[].saleTotal}
else
span #{data.tripOption[].saleTotal}
Because tripOption
is avaiable in data
object not in trips
Upvotes: 1