-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react2-week2/shahnawaz #328
base: main
Are you sure you want to change the base?
Conversation
Node week2/shahnawaz
…ges on hover, UUID used instead of id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work
@@ -0,0 +1,17 @@ | |||
# Database - change to fit your database | |||
DB_HOST = 0.0.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to always add this file to git ignore. It should not be committed to the repository since it contains sensitive information (password etc)
console.log("SQL", sql); | ||
|
||
try { | ||
const data = await query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct way to call query should be query()
, i.e. with brackets. But I'm not fully sure about this - it might be one of the new JavaScript syntax features.
In general, for backward compatibility, I recommend using empty brackets whenever you make a function call that takes no parameters :)
Who we are | ||
</h2> | ||
<p> | ||
HackYourFuture is a not-for-profit coding school for people with limited access to education and the labor market. The majority of our students worldwide are refugees. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to always format your code before committing to the repository. You can set VS Code to do this automatically every time you save, for example.
|
||
const deleteNote = (id) => { | ||
setNotes(notes.filter((n) => n.id !== id)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note with code formatting :)
try { | ||
const maxPrice = req.query.maxPrice; | ||
|
||
if (maxPrice !== undefined && isNaN(maxPrice)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JavaScript, it is always safer to check against both null and undefined. You can make use of the Falsy concept here and simply treat the value as a boolean: https://developer.mozilla.org/en-US/docs/Glossary/Falsy
The only thing to keep in mind is that 0 is also consider "false", so you may need to check for example like this:
if (maxPrice || maxPrice === 0)
const allMeals = await knex("meal").select("*"); | ||
response.json(allMeals); | ||
} catch (error) { | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the error to the user with a descriptive error message and status :)
Notice that just throwing the error from catch makes the catching redundant - it was being thrown anyways.
// Serve the built client html | ||
app.use(express.static(buildPath)); | ||
|
||
// Parse URL-encoded bodies (as sent by HTML forms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to aim for clear spacing between the different blocks of the code. That way, it will look nicer in code interviews, quizzes etc.
No description provided.