-
Notifications
You must be signed in to change notification settings - Fork 7
Assignment-w2-NodeJs #2
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
base: main
Are you sure you want to change the base?
Assignment-w2-NodeJs #2
Conversation
durw4rd
left a comment
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 job as far as programming goes! I noticed a few typos here and there and some minor opportunities for improvement, but you clearly mastered the topic taught in this module.
The main point of feedback from my side would be that you are not following the instructions very closely, and your app is actually likely rendering the wrong piece of data from the API. Lack of attention to detail can potentially be quite detrimental to the perception of your work.
| @@ -0,0 +1,5 @@ | |||
| import app from "./app.js"; | |||
| const PORT = process.env.PORT || 3000; | |||
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 that you're using an environment variable with a fallback.
| "name": "hackyourtemperature", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", |
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.
This should point to server.js since that's your main file.
| "cross-env": "^10.0.0", | ||
| "jest": "^30.0.5", | ||
| "nodemon": "^3.1.10", | ||
| "superset": "^2.0.1", |
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.
Possibly a typo? I don't see this package used anywhere in the project.
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.
This is an excellent addition that was not required in the instructions 👏
| router.post("/", async (req, res) => { | ||
| const { cityName } = req.body; | ||
| if (!cityName) { | ||
| res.status(400).render("home", { errorMessage: "City is required" }); |
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.
There should be a return statement to prevent further execution.
| const response = await fetch(URL); | ||
|
|
||
| const data = await response.json(); | ||
| res.render("weatherShow", { data }); |
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.
This is a point of preference and overall API design, but the instructions asked to return temperature info for the selected city. You are returning the entire blob of data, which then needs to be parsed by the requesting client. This can work, but the client needs to be aware of this fact.
| <title>Weather show</title> | ||
| </head> | ||
| <body> | ||
| <h1>{{data.name}} <b>{{data.main.temp_min}}</b></h1> |
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 didn't test the API, but this doesn't seem like the correct field for showing the actual temperature. I think it should be data.main.temp.
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.
To clarify, you should have replaced this and the babe.config.csj files with the examples from the assignment instructions.
No description provided.