Shadi A. - #21
Shadi A.#21shmoonwalker wants to merge 3 commits into
Conversation
📝 HackYourFuture auto gradeAssignment Score: 100 / 100 ✅Status: ✅ Passed Test Details |
| @@ -1,5 +1,5 @@ | |||
| // Change base URL for API requests to the local IP of the Post Central API server | |||
| const BASE_URL = 'http://localhost:3000'; | |||
| const BASE_URL = "https://postcentral.hyf.dev"; | |||
There was a problem hiding this comment.
oh yes, it could have been that too
|
|
||
| function authHeader(token) { | ||
| return { | ||
| Authorization: `Bearer ${token}`, |
| }); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to get user info: 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 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 update post: HTTP ${response.status} ${response.statusText}`, |
| }); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to delete post: HTTP ${response.status} ${response.statusText}`, |
JQnetherlands
left a comment
There was a problem hiding this comment.
Hello, Shadi.
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.
For now, you solution about the task 1 , it’s the one I like most! You did amazingly using for loop, I have to say it is well done and more important from an academic point of view, I have only several good things to say about it.
You clearly understand loops, that is very important because all the methods map(), forEach(), reduce(), etc are under the hood loops, if you dominate loop perfectly you can understand and use the other methods (map, forEach, Reduce) much better.
Loops are important because you have it in almost all the programming languages, maybe you don’t have a map() function in other language, but for sure loops, and with loops you can accomplish almost everything. Please keep the good basic knowledge as you are doing.
Some developers, teams, maybe will tell you that you should use methods instead of loops, just be aware that this preferences for the company or team you work for and in any case won’t erase that indeed you did an amazing job, but keep in mind that maybe in the future you should use (because they tell you) methods instead of loops.
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, you passed successfully and almost beyond expectations, please be proud of yourself and keep the good work! Congratulations
Complete All Tasks For Week 10