Handle API errors on the frontend by showing the error message