-
Notifications
You must be signed in to change notification settings - Fork 0
/
DespegarExtractor.js
40 lines (36 loc) · 1.46 KB
/
DespegarExtractor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module.exports = {
extract : function(body) {
//console.log(body);
var response = [];
return JSON.stringify(body);
/* var body = JSON.parse(body);
body.items.forEach(function(item) {
var data = {};
data.id = item.id;
data.outbound = item.outbound_choices[0];
data.inbound = item.inbound_choices[0];
data.price = item.price_detail;
response.push(data);
}, this);
var htmlResponse = "<table>";
response.forEach(function(data) {
htmlResponse+="<tr>";
htmlResponse+="<td>" + data.outbound.duration + "</td>";
data.outbound.segments.forEach(function(segment) {
htmlResponse+="<td>" + segment.from + "</td>";
htmlResponse+="<td>" + segment.to + "</td>";
htmlResponse+="<td>" + segment.duration + "</td>";
}, this);
htmlResponse+="<td>" + data.inbound.duration + "</td>";
data.inbound.segments.forEach(function(segment) {
htmlResponse+="<td>" + segment.from + "</td>";
htmlResponse+="<td>" + segment.to + "</td>";
htmlResponse+="<td>" + segment.duration + "</td>";
}, this);
htmlResponse+="<td>" + data.price.total + "</td>";
htmlResponse+="</tr>";
}, this);
htmlResponse+="</table>";
return htmlResponse;*/
}
};