Skip to content
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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

react2-week2/shahnawaz #328

wants to merge 25 commits into from

Conversation

shazkhan2
Copy link

No description provided.

@github-actions github-actions bot changed the title react2-week3/shahnawaz react2-week2/shahnawaz Feb 9, 2024
Copy link

@babak-f babak-f left a 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
Copy link

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;
Copy link

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.
Copy link

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));

Copy link

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)) {
Copy link

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;
Copy link

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)
Copy link

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.

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