gbowne1 / reactsocialnetwork

Social Media website/app made with React 18 & MUI v5
GNU General Public License v3.0
35 stars 59 forks source link

[feature]: Add error Handling to the API fetch for Login.jsx #358

Open gbowne1 opened 9 months ago

gbowne1 commented 9 months ago

Is your feature request related to a problem? Please describe.

It is related to a possible fetch problem in Login.jsx

It needs a .catch() to trap network errors and exceptions

There are some other related issues:

The handleAuthentication function is called after setting the snackbar options, but it's not clear if this function is asynchronous or if it needs to be awaited. If it's an async operation, might need to await it to ensure proper execution order.

Before sending the credentials to the server, there is no client-side validation to check if the userData fields are filled out or formatted correctly. It's a good practice to validate user input before making a network request.

Really shouldnt be using http because that makes it relatively insecure, but its ok in development

The function seems to be using some global functions or state management (setSnackbarOptions, setOpenSnackbar, handleAuthentication). This really needs some state management improvement

Also the code for setting the snackbar options and opening the snackbar is a little repetitive

Describe the solution you would like

Fixing some of the outlying issues with this Login.jsx

Describe the alternatives you have tried

N/A

Additional context

No response

Amrani-Farouk-Hossam-Eddine commented 9 months ago

i'm interesting in working on this issue if no one is working on it currently

gbowne1 commented 9 months ago

Ok @Amrani-Farouk-Hossam-Eddine

Nobody is working on it