Skip to content

Commit

Permalink
docs: fix collect examples (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallswain committed Nov 21, 2021
1 parent dc897db commit 66caa43
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,16 @@ const handle_error = (context) => {
/* Do some error handling */
}

const request_with_middleware = hooks(make_request, middleware(
collect({
before: [verify_auth],
after: [discard('password')],
error: [handle_error]
})
))
const request_with_middleware = hooks(
make_request,
middleware([
collect({
before: [verify_auth],
after: [discard('password')],
error: [handle_error]
})
])
)
```

Or with a class:
Expand All @@ -700,13 +703,18 @@ const handle_error = (context) => {
/* Do some error handling */
}

const request_with_middleware = hooks(DbAdapter, middleware({
create: collect({
before: [verify_auth],
after: [discard('password')],
error: [handle_error]
})
}))
const request_with_middleware = hooks(
DbAdapter,
{
create: middleware([
collect({
before: [verify_auth],
after: [discard('password')],
error: [handle_error]
})
]),
}
)
```

# Best practises
Expand Down

0 comments on commit 66caa43

Please sign in to comment.