Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

London-10-shadi-fakhri-node-week-1 #329

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Shadi38
Copy link

@Shadi38 Shadi38 commented Jul 20, 2023

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link

@ShayanMahnam ShayanMahnam left a comment

Choose a reason for hiding this comment

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

Well done, Shadi!
First, thank you for putting the "node_modules" in the gitignore file. You did everything correctly. I will now add some error handling for you, which will be useful in the future.


//...END OF YOUR CODE
// /quotes - Should return all quotes (json)
app.get("/quotes", (req, res) => {

Choose a reason for hiding this comment

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

app.get("/quotes", (req, res) => {
  if (quotes.length === 0) {
    return res.status(404).json({ error: "No quotes found." });
  }
  res.send({ quotes });
});

Copy link
Author

Choose a reason for hiding this comment

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

thanks, Shayan. you mentioned a good point. From now I will use it in my projects.

app.get("/quotes", (req, res) => {
res.send({quotes});
});
// /quotes/random - Should return ONE quote (json)

Choose a reason for hiding this comment

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

app.get("/quotes/random", (req, res) => {
  if (quotes.length === 0) {
    return res.status(404).json({ error: "No quotes found." });
  }

  const randomQuote = pickFromArray(quotes);
  res.send(randomQuote);
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants