Conversation
This comment has been minimized.
This comment has been minimized.
|
|
||
| // Add helper functions as needed here | ||
|
|
||
| function generateMarkdownContent(data) { |
There was a problem hiding this comment.
Well done, encapsulating your code in a function make it reusable
| } | ||
|
|
||
| function cocktailIngredients(drink) { | ||
| if (!drink) return; |
There was a problem hiding this comment.
Well done, encapsulating your code in a function make it reusable
|
|
||
| let ingredients = []; | ||
|
|
||
| for (let i = 1; i <= 15; i++) { |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to getMe : HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to login user: HTTP ${response.status} ${response.statusText}`, |
| }); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to create a post: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to get posts: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to delete user: HTTP ${response.status} ${response.statusText}`, |
| `Failed to delete post: HTTP ${response.status} ${response.statusText}`, | ||
| ); | ||
| } | ||
|
|
JQnetherlands
left a comment
There was a problem hiding this comment.
Hello, Yanna.
I will start with the good news! you have passed both task successfully, you almost have exceeds expectations ( almost 5 starts), now I will go on with the nices to have.
About task 1 you created two functions, that made your code reusable for future projects, You are in the right track, sometimes after you do a project , review the functions you made after a while maybe you will have that aha moment, where you see that you could have done refactoring in other way, that is a skill that only come with the time, what I advice you to review this project again after some time!
I do love that you used a for loop, well done, I invite you to think where else you could have done, for your personal grow!
About task 2, all your functions accomplish their goal , well done, each of one shows you do understand the CRUD and HTTP actions and what each Method needs to successfully fetch to the back end (GET, POST, UPDATE, DELETE).
The only feedback I have to write better code is the following:
Right now you have ---> Failed to delete post: HTTP ${response.status} ${response.statusText}
That would be ---> Failed to delete post: HTTP 403 forbidden
Do you think it is clear enough information for the user to know what went wrong?
Can you imagine a better statement for the user?
for example this you could do if you change your code a bit, I will give you the final expected output that I am talking about:
clearer output ---> Failed to delete post: HTTP 403 You can only modify your own posts
Do you see the difference? can you imagine how you could make your code give that example? HINT: maybe an inline conditional , do you know which one?
That you could apply to each function to make it more user friendly.
Again, you did super well overall, keep the good work! Congratulations
📝 HackYourFuture auto gradeAssignment Score: 93 / 100 ✅Status: ✅ Passed Test Details |
|
Refactor: improve error messages and code structure across tasks 1 & 2 Task 1:
Task 2:
Thanks to the instructor for the thoughtful feedback — it really helped me polish both tasks and see new ways to improve my code. This update makes the project more readable, user‑friendly and maintainable. |
Task 1 – Cocktail Recipe CLI: Built a small command‑line tool that retrieves cocktail data from TheCocktailDB API and saves the recipe as a Markdown file using async/await and fs/promises.
Task 2 – Post Central API Services: Completed the required API service functions for the CLI by implementing the missing GET, POST, PUT, and DELETE requests and connecting them to the existing project structure.