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

London10 - Bedi Omuri - Node- Week_1 - #323

Open
Bedi06 wants to merge 6 commits into
CodeYourFuture:masterfrom
Bedi06:master
Open

London10 - Bedi Omuri - Node- Week_1#323
Bedi06 wants to merge 6 commits into
CodeYourFuture:masterfrom
Bedi06:master

Conversation

@Bedi06

Copy link
Copy Markdown

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?

@ShayanMahnamShayanMahnam left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job Bedi!

  • Try to look at this Link to see whats the diffrence between .send and .json
  • I will now add some error handling for you, which will be useful in the future.

Comment threadserver.js
}


app.get("/echo",function(request,response){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

app.get("/echo",(req,res)=>{constwordQuery=req.query.word;if(!wordQuery){returnres.status(400).json({error: "Query parameter 'word' is missing."});}try{res.send(`You entered: ${wordQuery}`);}catch(error){res.status(500).json({error: "Internal Server Error"});}});

Comment threadserver.js
response.send(getRandomQuote);
});

app.get("/quotes/search",function(request,response){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

app.get("/quotes/search",(req,res)=>{constterm=req.query.term;if(!term){returnres.status(400).json({error: "Search term is missing in the query parameter."});}try{constquotesFound=quotesMatching(term);res.json(quotesFound);}catch(error){res.status(500).json({error: "Internal Server Error"});}});

Comment threadserver.js
response.send(quotes);
});

app.get("/quotes/random",function(request,response){

Copy link
Copy Markdown

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)=>{try{constrandomQuote=lodash.sample(quotes);res.json(randomQuote);}catch(error){res.status(500).json({error: "Internal Server Error"});}});

Comment threadserver.js
});

//START OF YOUR CODE...
app.get("/quotes",function (request,response){

Copy link
Copy Markdown

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)=>{try{res.json(quotes);}catch(error){res.status(500).json({error: "Internal Server Error"});}});

Sign up for freeto 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

@Bedi06@ShayanMahnam