diff --git a/docs/api/hooks.md b/docs/api/hooks.md index 2020f45..78978e7 100644 --- a/docs/api/hooks.md +++ b/docs/api/hooks.md @@ -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. diff --git a/docs/guide/advanced.md b/docs/guide/advanced.md index 5ef3712..3042efa 100644 --- a/docs/guide/advanced.md +++ b/docs/guide/advanced.md @@ -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 }) } ```