freeCodeCamp / classroom

BSD 3-Clause "New" or "Revised" License
144 stars 120 forks source link

fix: Only parse response body as json when server returns 200 in modal. #507

Closed roberthuskins closed 1 year ago

roberthuskins commented 1 year ago

Set up this project once again and went to create a class, I found some runtime error. It was because we were parsing json on a non 200 response from the API. Before/After pics included.

The reason why I was getting 403 was because my database was set up wrong so unlikely this error would show up in production, still better to handle errors properly on client side for any other kinds of errors (like 500 due to timeout).

Screenshot 2023-10-29 at 5 22 49 PM

Screenshot 2023-10-29 at 5 36 23 PM

Checklist:

GuillermoFloresV commented 1 year ago

Thanks for this fix, Rob.