fix: change res.end to .json

This commit is contained in:
Mateusz Pstrucha committed 2021-09-29 00:37:57 +02:00
1 parent 490d097e01
commit 353a88bc9c
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ const router = express.Router()
router.post('/batch/', ({ body: { tids } }, res) => {
if (tids === undefined) return res.status(400).end('Track ids array required')
if (tids.length < 1) return res.end([])
if (tids.length < 1) return res.send([])
Promise.all(tids.map((tid) => db.tracks.get(tid)))
.then((tracks) => res.send(tracks))
+3 -3
View File
@@ -24,7 +24,7 @@ router.post(
if (tids === undefined)
return res.status(400).end('List of Track ids required')
if (tids.length < 1) return res.end([])
if (tids.length < 1) return res.json([])
Promise.all([
Promise.all(tids.map((tid) => db.votes.getTrackStats(tid))),
@@ -112,7 +112,7 @@ router.patch(
db.votes
.putUserTrack(tid, id, value)
.then((ok) => {
res.end(ok.toString())
res.json(ok.toString())
console.info(`vote# ${id} ${value} ${tid}`)
})
.catch((err) => {
@@ -121,7 +121,7 @@ router.patch(
})
})
.catch((err) => {
res.end('false')
res.json('false')
console.error(err)
})
}