Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| const url = new URL(req.url, `http://${req.headers.host}`); | ||
|
|
||
| // Обробляємо тільки POST /add-expense | ||
| if (url.pathname === '/add-expense' && req.method === 'POST') { |
There was a problem hiding this comment.
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.
src/createServer.js
Outdated
| res.setHeader('Content-Type', 'application/json'); | ||
|
|
||
| return res.end(JSON.stringify(expense)); |
There was a problem hiding this comment.
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.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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! ✨
No description provided.