Add onerror callback to xhr request object
Throw an error if response status code is not OK