Conversation
There was a problem hiding this comment.
Hi Rena!
Thank you for your submission.
FEEDBACK:
- On unsuccessful login the user is still directed to the /feed/posts/ (see screenshot).
- Profile and JWT token is not stored in LocalStorage (see screenshot).
- User can’t create post (see screenshot).
- See detailed feedback in PR.
Unfortunately this cannot go through as a pass
Kind regards
N Moseki
| body | ||
| }); | ||
|
|
||
| const { accessToken, ...user } = await response.json(); |
| const method = "post"; | ||
| const action = "/auth/login"; | ||
|
|
||
|
|
| export async function registerUser(profile){ | ||
| const registerUrl = `${API_SOCIAL_URL}${API_AUTH}${API_REGISTER}`; | ||
| const body = JSON.stringify(profile); | ||
|
|
There was a problem hiding this comment.
-
There should be a
try/catchhere. -
A conditional statement to check if response is OK.
| }); | ||
|
|
||
| const result = await response.json(); | ||
| alert("You are now registered. Please log in to your account.") |
There was a problem hiding this comment.
This alert() is very basic and should have been inside a try/catch block
|
|
||
| const method = "post"; | ||
| const author = "?_author=true"; | ||
| //const action = "/posts"; |
There was a problem hiding this comment.
Commented out lines should be removed from final code - line 7.
|
|
||
| // USERNAME | ||
| const userName = document.createElement("h2"); | ||
| userName.innerHTML = `${postData.owner}`; |
There was a problem hiding this comment.
Refrain from using innerHTML for templating rather use document.createElement.
|
|
||
| const openFormBtn = document.createElement("button"); | ||
| openFormBtn.classList.add("fw-bold", "m-2", "fs-5", "bg-secondary", "border", "border-black", "border-2") | ||
| openFormBtn.innerHTML = `Add a comment <i class="bi bi-chat-right-quote"></i>`; |
There was a problem hiding this comment.
Refrain from using innerHTML for templating rather use document.createElement.
|
|
||
| const commentDate = document.createElement("time"); | ||
| commentDate.classList.add("d-block", "mt-n2", "fs-7") | ||
| commentDate.innerHTML = `${commentData.created.match(/^\d{4}-\d{2}-\d{2}/)}`; |
There was a problem hiding this comment.
Refrain from using innerHTML for templating rather use document.createElement.
| } else if (isLiked) { | ||
| likeCountValue--; | ||
| likeCount.textContent = `${likeCountValue} Stars`; | ||
| likeBtn.innerHTML = `<i class="bi bi-star"></i>`; |
There was a problem hiding this comment.
Refrain from using innerHTML for templating rather use document.createElement.
| likeCountValue++; | ||
| likeCount.textContent = `${likeCountValue + storage.load(`liked_${postId}`)} Stars`; | ||
| likeBtn.classList.add("liked"); | ||
| likeBtn.innerHTML = `<i class="bi bi-star-fill text-secondary"></i>`; |
There was a problem hiding this comment.
Refrain from using innerHTML for templating rather use document.createElement.
Further development of CSS Frameworks with JavaScript.
Includes JS: