mirror of https://github.com/sundowndev/http.git
docs: try ts for syntax highlight
parent
d61ed49a92
commit
a6f21956ac
|
@ -11,8 +11,9 @@ The `arguments` listed below are those your hook will receive when it's called.
|
||||||
|
|
||||||
- arguments: `(config)`
|
- arguments: `(config)`
|
||||||
|
|
||||||
**Example: **
|
**Example:**
|
||||||
```js{}[plugins/http.js]
|
|
||||||
|
```ts [plugins/http.js]
|
||||||
export default function ({ $http }) {
|
export default function ({ $http }) {
|
||||||
$http.onRequest(config => {
|
$http.onRequest(config => {
|
||||||
console.log('Making request to ' + config.url)
|
console.log('Making request to ' + config.url)
|
||||||
|
@ -26,8 +27,9 @@ See [here](/advanced#hooks) for advanced usage.
|
||||||
|
|
||||||
- arguments: `(request, options, response)`
|
- arguments: `(request, options, response)`
|
||||||
|
|
||||||
**Example: **
|
**Example:**
|
||||||
```js{}[plugins/http.js]
|
|
||||||
|
```ts [plugins/http.js]
|
||||||
export default function ({ $http }) {
|
export default function ({ $http }) {
|
||||||
$http.onResponse((req, options, res) => {
|
$http.onResponse((req, options, res) => {
|
||||||
console.log('Making request to ' + req.url)
|
console.log('Making request to ' + req.url)
|
||||||
|
@ -45,8 +47,9 @@ See [here](/advanced#hooks) for advanced usage.
|
||||||
|
|
||||||
If the error originated from a request.
|
If the error originated from a request.
|
||||||
|
|
||||||
**Example: **
|
**Example:**
|
||||||
```js{}[plugins/http.js]
|
|
||||||
|
```ts [plugins/http.js]
|
||||||
export default function ({ $http, redirect }) {
|
export default function ({ $http, redirect }) {
|
||||||
$http.onError((err) => {
|
$http.onError((err) => {
|
||||||
// In case of unauthorized, redirect to a specific page
|
// In case of unauthorized, redirect to a specific page
|
||||||
|
|
Loading…
Reference in New Issue