Skip to content

Js2#295

Open
Siggen97 wants to merge 34 commits intoNoroffFEU:mainfrom
Siggen97:js2
Open

Js2#295
Siggen97 wants to merge 34 commits intoNoroffFEU:mainfrom
Siggen97:js2

Conversation

@Siggen97
Copy link

My JS2 pull request. Assignment Javascript 2 (resit).
oct 2022 full time student.
Using Noroff Api Doc v1

Copy link

@Paris2020 Paris2020 left a comment

Choose a reason for hiding this comment

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

Hi Sigrid

More detailed feedback can be found on Moodle.

Kind regards
N Moseki

userAvatarContainer.src = !!json.avatar ? json.avatar : "../images/no_avatar.jpg";
} catch (error) {
// THROW ERROR
throw new Error(error);

Choose a reason for hiding this comment

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

Catching an error and then throwing it does not make sense.

alert("Invalid email or password");
}
} catch (error) {
throw new Error(error, "An error occurred!");

Choose a reason for hiding this comment

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

The same comment about catching an error and then throwing it applies here as well.

// Display error message
userPostsContainer.innerHTML = errorMessage;
// Rethrow the error for external handling, if necessary
throw new Error(error);

Choose a reason for hiding this comment

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

Just keep this habit in mind in the future please - catching an error and then throwing it.

singlePostContainer.innerHTML = errorMessage;

// Rethrow the error for external handling, if necessary
throw new Error(error);

Choose a reason for hiding this comment

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

Same comment as mentioned before.

return json;
} catch (error) {
// THROW ERROR
throw new Error("An error occurred during the fetch operation", error);

Choose a reason for hiding this comment

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

Same comment as mentioned above.

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