Below is corrected json.
in node, I just want to be able to send onwardTrips.tripId
even something as simple as this, not being rendered in the view.
server.js
getTrips: function getTrips(req, res, next){
var url =
'http://ec2-54-251-114-65.ap-southeast-1.compute.amazonaws.com:8080/CTB-WS/rest/trips?from='+
req.tripinfo.fromCityId + '&to=' + req.tripinfo.toCityId + '&depart-date='
+ req.tripinfo.departDate+ '&pax=1';
console.log(url);
rest.get(url).on('complete', function(trips) {
if (trips instanceof Error) {
console.log('Error:', trips.message);
} else {
console.log('trips'+ JSON.stringify(trips); // shows in the
console
req.trips = JSON.stringify(trips);
next();
//res.json(JSON.stringify(destinationCities[sourceCitiesId]));
}
});
},
sendTrips: function sendTrips(req, res, next){
res.render('trips', {trips : req.trips});
}
view
extends layout
block content
h3 Trips selection
form.form-horizontal(id="Findtrips", accept-charset="UTF-8",
action="#", method="post" enctype="multipart/form-data")
each trip in trips
p {#trip.tripId}
{
"onwardTrips": [
{
"tripId": "1284792",
"fromCity": "Singapore",
"toCity": "Malacca",
"operatorCode": "SA",
"operatorName": "Starmart Express",
"departTime": "2014-01-20 14:00:00.0",
"busType": "Executive",
"pickupPointDetails": [
{
"pickupPointId": "78",
"departureTime": "2014-01-20 14:00:00.0",
"pickupPointName": "Golden Mile Tower, Beach Road"
}
],
"dropoffPointDetails": [
{
"dropOffPointName": "Melaka Sentral",
"dropOffPointId": "1284792"
}
],
"fareDetails": {
"adultFare": "65.0"
}
},
{
"tripId": "1285170",
"fromCity": "Singapore",
"toCity": "Malacca",
"operatorCode": "SA",
"operatorName": "Starmart Express",
"departTime": "2014-01-20 20:00:00.0",
"busType": "Executive",
"pickupPointDetails": [
{
"pickupPointId": "78",
"departureTime": "2014-01-20 20:00:00.0",
"pickupPointName": "Golden Mile Tower, Beach Road"
}
],
"dropoffPointDetails": [
{
"dropOffPointName": "Melaka Sentral",
"dropOffPointId": "1285170"
}
],
"fareDetails": {
"adultFare": "65.0"
}
},
{
"tripId": "1285254",
"fromCity": "Singapore",
"toCity": "Malacca",
"operatorCode": "SA",
"operatorName": "Starmart Express",
"departTime": "2014-01-20 23:00:00.0",
"busType": "Executive",
"pickupPointDetails": [
{
"pickupPointId": "78",
"departureTime": "2014-01-20 23:00:00.0",
"pickupPointName": "Golden Mile Tower, Beach Road"
}
],
"dropoffPointDetails": [
{
"dropOffPointName": "Melaka Sentral",
"dropOffPointId": "1285254"
}
],
"fareDetails": {
"adultFare": "65.0"
}
}
],
"errorCode": 0
}
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.