Skip to content

homework complete#14

Open
Alexlied wants to merge 1 commit into
pce-uw-jscript400:masterfrom
Alexlied:master
Open

homework complete#14
Alexlied wants to merge 1 commit into
pce-uw-jscript400:masterfrom
Alexlied:master

Conversation

@Alexlied
Copy link
Copy Markdown

No description provided.

Comment thread app.js
}
else {
const fruitIndex = fruits.indexOf(fruit);
fruits[fruitIndex] = { id: id, ...req.body }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to construct a new object inside a GET ONE route. Right now, this route is only returning the ID because of it.

Comment thread app.js

res.status(200).json({
message: 'Handling POST requests to /fruits'
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having two res.json()s will cause the following error to surface:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

I think this is also causing some problems later on to make the GET ALL /fruits request.

Comment thread app.js

const updatedFruits = fruits.filter(fruits => fruits.id !== id)

console.log(updatedFruits)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove console.log() statements before committing, please!

Comment thread app.js

res.status(200).json({
message: 'Deleted message'
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same thing here, you should only be responding once per route (unless you have some kind of if/else)

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