Skip to content

Commit b5d1173

Browse files
committed
docs: update wording on usage
Updates the usage to make it clear you can now import `request` rather than using `chai.request`.
1 parent aa205ee commit b5d1173

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ This is an addon plugin for the [Chai Assertion Library](https://www.chaijs.com/
2020
Use this plugin as you would all other Chai plugins.
2121

2222
```js
23-
import chaiModule from "chai";
23+
import * as chai from "chai";
2424
import chaiHttp from "chai-http";
2525

26-
const chai = chaiModule.use(chaiHttp);
26+
chai.use(chaiHttp);
27+
28+
// if you need to access `request`
29+
import {default as chaiHttp, request} from "chai-http";
30+
chai.use(chaiHttp);
31+
request.get(...).send(...);
2732
```
2833

2934
To use Chai HTTP on a web page, please use the latest v4 version for now.
@@ -89,7 +94,7 @@ Once a request is created with a given VERB (get, post, etc), you chain on these
8994
| `.set(key, value)` | Set request headers |
9095
| `.send(data)` | Set request data (default type is JSON) |
9196
| `.type(dataType)` | Change the type of the data sent from the `.send()` method (xml, form, etc) |
92-
| `.attach(field, file, attachment)` | Attach a file |
97+
| `.attach(field, file, attachment)` | Attach a file |
9398
| `.auth(username, password)` | Add auth headers for Basic Authentication |
9499
| `.query(parmasObject)` | Chain on some GET parameters |
95100

@@ -139,12 +144,12 @@ chai.request.execute(app)
139144
chai.request.execute(app)
140145
.get('/protected')
141146
.auth('user', 'pass')
142-
147+
143148
// Authenticate with Bearer Token
144149
chai.request.execute(app)
145150
.get('/protected')
146-
.auth(accessToken, { type: 'bearer' })
147-
151+
.auth(accessToken, { type: 'bearer' })
152+
148153
```
149154

150155
`.query()`

0 commit comments

Comments
 (0)