From bcf9f95c6dd5dbc13398f77ba5f88a4734092901 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sat, 21 Nov 2020 17:49:38 +0100 Subject: [PATCH] fix: do not use ?. operator for node 10 --- models/Track.js | 2 +- routes/api/tracks.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/Track.js b/models/Track.js index 557e633..f4d441e 100644 --- a/models/Track.js +++ b/models/Track.js @@ -40,7 +40,7 @@ TrackSchema.methods.toJSONFor = function (user, include) { visibleForAll: this.author ? this.author.areTracksVisibleForAll : false, visible: this.visible, author: this.author.toProfileJSONFor(user), - ...(include?.body ? { body: this.body } : {}), + ...(include && include.body ? { body: this.body } : {}), }; }; diff --git a/routes/api/tracks.js b/routes/api/tracks.js index a967158..6a52aa4 100644 --- a/routes/api/tracks.js +++ b/routes/api/tracks.js @@ -162,7 +162,7 @@ router.post( const trackData = new TrackData(); track.trackData = trackData._id; - if (req.body.track.body?.trim()) { + if (req.body.track.body && req.body.track.body.trim()) { trackData.points = []; addPointsToTrack({ trackData }, track.body); } @@ -311,7 +311,7 @@ router.put('/:track', auth.required, async function (req, res, next) { req.track.description = req.body.track.description; } - if (req.body.track.body?.trim()) { + if (req.body.track.body && req.body.track.body.trim()) { req.track.body = req.body.track.body.trim(); let trackData = await TrackData.findById(req.track.trackData);