Revamp sendRequest.js, make it more error-prone