Skip to content

Week 2 exercise completed#25

Open
drubini90 wants to merge 1 commit intopce-uw-jscript400:masterfrom
drubini90:master
Open

Week 2 exercise completed#25
drubini90 wants to merge 1 commit intopce-uw-jscript400:masterfrom
drubini90:master

Conversation

@drubini90
Copy link

No description provided.

{
id: "vtrDZT-Rf",
name: "pear",
price: "1.00"
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like in one case you're using strings and in the other using a number. I'd be consistent here.

// 01 - GET /vegetables?name=[partial-query]
// ===============================================
app.get("/vegetables", (req, res, next) => {
if (req.query) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work, unfortunately. req.query will always be an object, even if it's an empty object, and any object will be evaluated as truthy. To fix this, you should have req.query.name.

// 5 - GET /fruits?name=[partial-query]
// ===============================================
app.get("/fruits", (req, res, next) => {
if (req.query) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same problem here.

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.

3 participants