Skip to content

Comments

initial commit#8

Open
nsLittle wants to merge 4 commits intoprojectshft:mainfrom
nsLittle:main
Open

initial commit#8
nsLittle wants to merge 4 commits intoprojectshft:mainfrom
nsLittle:main

Conversation

@nsLittle
Copy link

So ugly, but it works...

app/page.js Outdated
useSelector((state) => state.weather);

const handleSearch = () => {
console.log(searchInput);
Copy link

Choose a reason for hiding this comment

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

Remember to clean up console.log in code - should only be used for troubleshooting.

Copy link
Author

Choose a reason for hiding this comment

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

UgH! I get so excited about submitting the evals because I'm so sick of looking at my wonky apps...

app/page.js Outdated

const handleSearch = () => {
console.log(searchInput);
if (searchInput.trim() !=='') {
Copy link

Choose a reason for hiding this comment

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

nitpick: spacing
if (searchInput.trim() !== '') {

Copy link
Author

Choose a reason for hiding this comment

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

Duly noted.

export const fetchWeather = createAsyncThunk(
'weather/fetchWeatherData',
async (city, thunkAPI) => {
try {
Copy link

Choose a reason for hiding this comment

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

nice job adding in try catch

'weather/fetchWeatherData',
async (city, thunkAPI) => {
try {
const response = await axios.get(`https://api.openweathermap.org/data/2.5/forecast?q=${city}&appid=1a8c344b0aaddd77f2a53a70916ddc5b&units=imperial`);
Copy link

Choose a reason for hiding this comment

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

recommend separating out appid as a variable

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand this?!?

Copy link

@lmicek lmicek May 20, 2024

Choose a reason for hiding this comment

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

I don't understand this?!?

like this
const appID = '1a8c344b0aaddd77f2a53a70916ddc5b';
&appid=${appID}

Choose a reason for hiding this comment

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

I support this comment

@nsLittle
Copy link
Author

I made some edits based on Laura's comments. Should be slightly better than last version.

@nsLittle
Copy link
Author

Rony/Laura. Hopefully I am submitting the correct version this time. Pretty sure I executed the git commit/push correctly this time. Thank you as always.

</a>
dispatch(fetchWeather(searchInput))
.then((response) => {
if (response.payload.cod === '404') {

Choose a reason for hiding this comment

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

interesting that the interface is .cod and not .code

</ul>
<ul>
<li className='data'>5-day average: {calculateAverage(result.data.list, 'humidity')}</li>
</ul>

Choose a reason for hiding this comment

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

this html is a bit long and hard to understand, there's logic also that could have been extracted to functions to help with readability

'weather/fetchWeatherData',
async (city, thunkAPI) => {
try {
const response = await axios.get(`https://api.openweathermap.org/data/2.5/forecast?q=${city}&appid=1a8c344b0aaddd77f2a53a70916ddc5b&units=imperial`);

Choose a reason for hiding this comment

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

I support this comment

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.

3 participants