Merge pull request #634 from lucaperret/master

doc(XHRUpload): fix getResponseError signature
This commit is contained in:
Artur Paikin 2018-02-18 12:47:52 -05:00 committed by GitHub
commit dbc9404139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,7 +106,7 @@ getResponseData (xhr) {
}
```
### `getResponseError(xhr)`
### `getResponseError(xhr.responseText, xhr)`
If the upload endpoint responds with a non-2xx status code, the upload is assumed to have failed.
The endpoint might have responded with some information about the error, though.
@ -115,7 +115,7 @@ Pass in a `getResponseError` function to extract error data from the `XMLHttpReq
For example, if the endpoint responds with a JSON object containing a `{ message }` property, this would show that message to the user:
```js
getResponseError (xhr) {
getResponseError (responseText, xhr) {
return new Error(JSON.parse(xhr.response).message)
}
```