Add error handling on API request failure