Add response codes of trip and routability queries

This commit is contained in:
Michael Krasnyk 2017-05-10 00:03:12 +02:00 committed by Patrick Niklaus
parent e2b7e8a4da
commit a44b63fbb9
2 changed files with 6 additions and 3 deletions

View File

@ -126,6 +126,7 @@ module.exports = function () {
r.query = this.query;
r.json = JSON.parse(body);
r.code = r.json.code;
r.status = res.statusCode === 200 ? 'x' : null;
if (r.status) {
r.route = this.wayList(r.json.routes[0]);

View File

@ -29,8 +29,10 @@ module.exports = function () {
}
var json;
got.code = 'unknown';
if (res.body.length) {
json = JSON.parse(res.body);
got.code = json.code;
}
if (headers.has('status')) {
@ -153,11 +155,11 @@ module.exports = function () {
if (row.source) {
params.source = got.source = row.source;
}
}
if (row.destination) {
params.destination = got.destination = row.destination;
}
}
if (row.hasOwnProperty('roundtrip')) { //roundtrip is a boolean so row.roundtrip alone doesn't work as a check here
params.roundtrip = got.roundtrip = row.roundtrip;