fix: do not use ?. operator for node 10

This commit is contained in:
Paul Bienkowski 2020-11-21 17:49:38 +01:00
parent 7aa6e0be84
commit bcf9f95c6d
2 changed files with 3 additions and 3 deletions

View file

@ -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 } : {}),
};
};

View file

@ -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);