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

Mikas happy thoughts project #107

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

Mikas happy thoughts project #107

wants to merge 3 commits into from

Conversation

mikaeber
Copy link

@mikaeber mikaeber changed the title requirements fulfilled Mikas happy thoughts project Oct 27, 2024
Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

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

Hi Mika! For upcoming projects I'd love to see you commit a bit more often. See it as your way to save your progress whenever you've implemented a feature or new functionality.

You've split your components into manageable components and you've done a nice job copying the design too. I put some comments throughout your code to think about for upcoming projects.

Comment on lines +7 to +25
try {
const res = await fetch(URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ message: message }),
});

if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}

const data = await res.json();
setThoughts((prevThoughts) => [data, ...prevThoughts]);
setMessage("");
} catch (error) {
console.error("Error submitting thought:", error);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice with try/catch!

Comment on lines +34 to +39
<input
type="text"
value={message}
onChange={(e) => setMessage(e.target.value)}
required
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget labels when working with form elements! And perhaps this should be a textarea since it's a multiline input?

return data;
};

export const formatTimeAgo = (timestamp) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! However, does this really belong in an api.js file? 👀

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