Added error handling for xhr fails during fetch