Skip to content

Solution#184

Open
VictorKomara wants to merge 2 commits intomate-academy:masterfrom
VictorKomara:develop
Open

Solution#184
VictorKomara wants to merge 2 commits intomate-academy:masterfrom
VictorKomara:develop

Conversation

@VictorKomara
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job on implementing the server-side logic for handling the POST request and saving the expense data! The core functionality is solid. However, a couple of key requirements are missing, so I am requesting changes.

First, the server needs to provide the HTML form to the user. Currently, it only handles the POST /add-expense request. You should add a handler for a GET request to the root path (/) that sends the HTML form as a response.

Second, after successfully saving an expense, the server should return an HTML page that displays the saved JSON. Your implementation currently returns raw JSON with a Content-Type of application/json. Please update this to send a response with Content-Type: text/html and wrap the JSON data in basic HTML tags, like <pre>, so it renders as a webpage.

Addressing these two points will make your solution complete. Keep up the good work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

const url = new URL(req.url, `http://${req.headers.host}`);

// Обробляємо тільки POST /add-expense
if (url.pathname === '/add-expense' && req.method === 'POST') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task requires the application to show an HTML form. This server only handles the POST /add-expense request. You should also implement a handler for a GET request (e.g., to the root path /) that serves the HTML form to the user.

Comment on lines +36 to +38
res.setHeader('Content-Type', 'application/json');

return res.end(JSON.stringify(expense));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the task description, the server should "return an HTML page with well formatted JSON". This means the Content-Type header should be text/html and the body should be an HTML document that displays the JSON data, not a raw JSON response.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Excellent work on this iteration! I am approving your solution as you've successfully addressed all the feedback from the previous review. The server now correctly handles the GET request to serve the form and returns a well-formatted HTML page after a successful POST request. Your implementation now fully meets all the requirements of the task. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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