Skip to content

Exercise mongoDB#15

Open
katrinagd wants to merge 2 commits intopce-uw-jscript400:masterfrom
katrinagd:master
Open

Exercise mongoDB#15
katrinagd wants to merge 2 commits intopce-uw-jscript400:masterfrom
katrinagd:master

Conversation

@katrinagd
Copy link

No description provided.

// POST /api/books/:bookId/authors - not working
router.post('/:id/authors/', async (req, res, next) => {
const status = 201
const book = await Books.findById(req.params.bookId)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are requesting the wrong param, as per your code should be
const book = await Books.findById(req.params.bookId)

const status = 200
const response = books.find(({ id }) => id === req.params.id)
const index = books.indexOf(response)
const book = await Books.findById({authorId:req.params.authorId})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searching using the wrong params try:
const book = await Books.findById({_id: req.params.id})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants