Skip to content

Conversation

@joheri1
Copy link

@joheri1 joheri1 commented Dec 7, 2024

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

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

Good job Johanna! Just remember going forward to make use of query params instead of creating different endpoints to filter.

Comment on lines +35 to +39
app.get("/elves/all", (request, response) => {

// Return all elves
response.json(elves);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Hehe love the dataset! A more RESTful approach would be to name this endpoint just /elves and then have different query params to use as filters, e.g.
/elves?top-twelves=true
/elves?title=backend dasher

Comment on lines +86 to +89
app.get("/test", (request, response) => {
response.send("Jingle bells, the server tells, it's up and running well!");
console.log("Jingle bells, the server tells, it's up and running well!");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

😆 ⭐

Comment on lines +71 to +80
app.get("/elves/:id", (request, response) => {
const id = request.params.id;

const elf = elves.find((record) => record.elfID === +id);
if (elf) {
response.status(200).json(elf);
} else {
response.status(404).send("404 - No elf found with that ID");
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice error handling

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