fix: send username
as well in response when insert an exercise
This commit is contained in:
parent
3334c14beb
commit
6e84cd0613
8
index.js
8
index.js
@ -88,9 +88,10 @@ app.post("/api/users/:_id/exercises", (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exerciseLogs
|
exerciseLogs
|
||||||
.exists({ _id: _id })
|
.findById(_id)
|
||||||
.then((userExists) => {
|
.select({ username: 1 })
|
||||||
if (userExists) {
|
.then((user) => {
|
||||||
|
if (user) {
|
||||||
exerciseLogs
|
exerciseLogs
|
||||||
.updateOne(
|
.updateOne(
|
||||||
{ _id: _id },
|
{ _id: _id },
|
||||||
@ -109,6 +110,7 @@ app.post("/api/users/:_id/exercises", (req, res) => {
|
|||||||
if (excLogs.modifiedCount) {
|
if (excLogs.modifiedCount) {
|
||||||
res.json({
|
res.json({
|
||||||
_id: _id,
|
_id: _id,
|
||||||
|
username: user.username,
|
||||||
description: description,
|
description: description,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
date: new Date(date).toDateString(),
|
date: new Date(date).toDateString(),
|
||||||
|
Loading…
Reference in New Issue
Block a user