Skip to content

Commit 13e7fc1

Browse files
committed
Updated README.md
1 parent d8f5f8a commit 13e7fc1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const dispatch = function (req, res) {
1919

2020
const server = http.createServer(dispatch)
2121

22-
inject(dispatch, { method: 'get', url: '/' }, (res) => {
22+
inject(dispatch, { method: 'get', url: '/' }, (err, res) => {
2323
console.log(res.payload)
2424
})
2525
```
@@ -30,10 +30,15 @@ Async await and promises are supported as well!
3030
// promises
3131
inject(dispatch, { method: 'get', url: '/' })
3232
.then(res => console.log(res.payload))
33+
.catch(console.log)
3334

3435
// async-await
35-
const res = await inject(dispatch, { method: 'get', url: '/' })
36-
console.log(res.payload)
36+
try {
37+
const res = await inject(dispatch, { method: 'get', url: '/' })
38+
console.log(res.payload)
39+
} catch (err) {
40+
console.log(err)
41+
}
3742
```
3843

3944
## API
@@ -60,7 +65,8 @@ Injects a fake request into an HTTP server.
6065
- `close` - whether the request will emit a `close` event. Defaults to `undefined`, meaning no `close` event will be emitted.
6166
- `validate` - Optional flag to validate this options object. Defaults to `true`.
6267
- `server` - Optional http server. It is used for binding the `dispatchFunc`.
63-
- `callback` - the callback function using the signature `function (res)` where:
68+
- `callback` - the callback function using the signature `function (err, res)` where:
69+
- `err` - error object
6470
- `res` - a response object where:
6571
- `raw` - an object containing the raw request and response objects where:
6672
- `req` - the simulated request object.
@@ -74,7 +80,7 @@ Injects a fake request into an HTTP server.
7480

7581
#### `inject.isInjection(obj)`
7682

77-
Checks if given object `obj` is a Shot `Request` object.
83+
Checks if given object `obj` is a *light-my-request* `Request` object.
7884

7985
## Acknowledgements
8086
This project has been forked from [`hapi/shot`](https://github.com/hapijs/shot) because we wanted to support *Node ≥ v4* and not only *Node ≥ v8*.

0 commit comments

Comments
 (0)