freeCodeCamp / classroom

BSD 3-Clause "New" or "Revised" License
145 stars 119 forks source link

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

Closed roberthuskins closed 8 months ago

roberthuskins commented 8 months 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 8 months ago

Thanks for this fix, Rob.