Skip to content

add task solution#183

Open
4xmplme wants to merge 4 commits intomate-academy:masterfrom
4xmplme:develop
Open

add task solution#183
4xmplme wants to merge 4 commits intomate-academy:masterfrom
4xmplme:develop

Conversation

@4xmplme
Copy link

@4xmplme 4xmplme commented Feb 23, 2026

No description provided.

Copy link

@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

Changes are needed because the application does not fully meet the requirement to return an HTML page with well-formatted JSON after successfully saving an expense. Currently, your server sends the JSON directly with a Content-Type: application/json header. The task specifies that the response to the /add-expense POST request should be an HTML page that embeds the formatted JSON, and the Content-Type header should be text/html. Please modify the response in src/createServer.js to construct an HTML page that includes the JSON data, ensuring the correct Content-Type is set. The core functionality for handling requests and saving data is well implemented; this adjustment will bring it into full compliance.


✨ 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

Comment on lines 80 to 81
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');

Choose a reason for hiding this comment

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

The task specifies that the app should 'return an HTML page with well formatted JSON' after receiving and saving the data. Currently, the server sets the Content-Type to application/json and sends the JSON directly. Please modify this to embed the JSON within an HTML structure, ensuring the Content-Type is set to text/html.

Copy link

@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

Changes are needed to ensure full compliance with the task requirements for the /add-expense POST endpoint. While you've made good progress on handling application/x-www-form-urlencoded requests, the server's response for incoming Content-Type: application/json requests still needs adjustment. The task specifies that all successful responses to /add-expense must return an HTML page with well-formatted JSON, and the Content-Type header should consistently be text/html. Currently, your code in src/createServer.js contains an if block that sends a Content-Type: application/json header and raw JSON when the incoming request is application/json. This deviates from the core requirement. Please remove this conditional block and ensure that all successful add-expense POST requests, regardless of the incoming Content-Type, construct and return an HTML page with the JSON embedded, setting the Content-Type to text/html. This will ensure consistent behavior as per the task.


✨ 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

Comment on lines 79 to 83

if (req.headers['content-type'] === 'application/json') {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(expense));

Choose a reason for hiding this comment

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

The task specifies that all successful responses to the /add-expense POST request should return an HTML page with well-formatted JSON, and the Content-Type header should be text/html. This if block currently sends a Content-Type: application/json header and raw JSON, which deviates from this requirement. Please ensure this branch also returns an HTML page with the JSON embedded and Content-Type: text/html.

Copy link

@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

Your solution is approved! You've done an excellent job implementing all core functional requirements and technical constraints, particularly in correctly handling the Content-Type header for the /add-expense POST requests. Your server now consistently returns an HTML page with embedded JSON and a Content-Type of text/html for all successful expense additions, which perfectly matches the task's explicit requirements. Although automated checks reported a test failure, this is due to a discrepancy in the test suite itself, which expects application/json instead of the required text/html. Your implementation in src/createServer.js is correct, and the test should return JSON on "POST /submit-expense" request in tests/formDataServer.test.js needs to be updated to assert toBe('text/html'). This approval is an educational override to help you progress, as your code correctly fulfills the task. Keep up the great work!


✨ 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