TheYuriG/REST-frontend

Refactor the error handler for fetch API calls

Closed this issue · 1 comments

After completing issue #1, we will have an issue with the default error handler we use in our functions.

Our error handlers will need to be updated accordingly and refactored. We currently check twice for resData.errors which is wasted computational power, considering that if the first if check succeded, we would throw an error and the second wouldn't run regardless.

Refactor the code to only check for resData.errors once and then safely check resData.errors[0].status using the safe call operator .?.

This issue is now completed thanks to PR #3.

React version used for the frontend can't compile using the safe call operator, so I had to remove that on the following commit where I fixed the comments.