Skip to content

Commit

Permalink
Add check to prevent undefined error when determining order of concat
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewmeyer committed Jul 8, 2018
1 parent e2c61bd commit 78a33e2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/controllers/launches.js
Expand Up @@ -53,8 +53,12 @@ module.exports = {
.sort(sortQuery(ctx.request))
.limit(limitQuery(ctx.request))
.toArray();
if (past[past.length - 1].flight_number === 1) {
data = upcoming.concat(past);
if (past.length !== 0) {
if (past[past.length - 1].flight_number === 1) {
data = upcoming.concat(past);
} else {
data = past.concat(upcoming);
}
} else {
data = past.concat(upcoming);
}
Expand Down

0 comments on commit 78a33e2

Please sign in to comment.