Skip to content

Commit

Permalink
docs: update onError usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed Jun 16, 2020
1 parent 6329d02 commit e42eb1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/api/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ See [here](/guide/advanced.html#hooks) for usage.

- arguments: `(error)`

If the error originated from a request, the property `err.response` might be available.
If the error originated from a request.

Available properties:

- `error.statusCode`
- `error?.response?.data`

You can optionally return a value or promise that can resolve for fallback response. If hook returns any value, other hooks **won't** be called.

See [here](/guide/advanced.html#hooks) for usage.
4 changes: 3 additions & 1 deletion docs/guide/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export default function ({ $http }) {
})

$http.onError(error => {
if(error.response.status === 500) {
if(error.statusCode === 500) {
alert('Request Error!')
}
// Tip: You can use error.response?.data? to get response message
// Tip: You can return another a fallback response (or promise) to avoid rejection
})
}
```
Expand Down

0 comments on commit e42eb1c

Please sign in to comment.