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 intoCodeYourFuture:masterfrom
Open
London10 - Bedi Omuri - Node- Week_1#323Bedi06 wants to merge 6 commits intoCodeYourFuture:masterfrom
Bedi06 wants to merge 6 commits intoCodeYourFuture:masterfrom
Conversation
ShayanMahnam
left a comment
There was a problem hiding this comment.
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.
| } | ||
|
|
||
|
|
||
| app.get("/echo",function(request,response){ |
There was a problem hiding this comment.
app.get("/echo", (req, res) => {
const wordQuery = req.query.word;
if (!wordQuery) {
return res.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" });
}
});| response.send(getRandomQuote); | ||
| }); | ||
|
|
||
| app.get("/quotes/search",function(request,response){ |
There was a problem hiding this comment.
app.get("/quotes/search", (req, res) => {
const term = req.query.term;
if (!term) {
return res.status(400).json({ error: "Search term is missing in the query parameter." });
}
try {
const quotesFound = quotesMatching(term);
res.json(quotesFound);
} catch (error) {
res.status(500).json({ error: "Internal Server Error" });
}
});| response.send(quotes); | ||
| }); | ||
|
|
||
| app.get("/quotes/random",function(request,response){ |
There was a problem hiding this comment.
app.get("/quotes/random", (req, res) => {
try {
const randomQuote = lodash.sample(quotes);
res.json(randomQuote);
} catch (error) {
res.status(500).json({ error: "Internal Server Error" });
}
});| }); | ||
|
|
||
| //START OF YOUR CODE... | ||
| app.get("/quotes",function (request,response){ |
There was a problem hiding this comment.
app.get("/quotes", (req, res) => {
try {
res.json(quotes);
} catch (error) {
res.status(500).json({ error: "Internal Server Error" });
}
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?