@@ -3,30 +3,32 @@ An opinionated, isomorphic HTTP client for Node.js, browsers, and React Native.
3
3
4
4
### Usage
5
5
6
- #### Import httpClient (Node.js)
6
+ #### Import httpClient (Node.js, browsers, or React Native )
7
7
``` js
8
- import https from ' https' ;
9
8
import {httpClient } from ' @digitalbazaar/http-client' ;
10
9
```
11
10
12
- #### Import httpClient (browsers or React Native)
11
+ #### Import and initialize a custom Bearer Token client
13
12
``` js
14
13
import {httpClient } from ' @digitalbazaar/http-client' ;
14
+
15
+ const accessToken = ' 12345' ;
16
+ const headers = {Authorization: ` Bearer ${ accessToken} ` };
17
+
18
+ const client = httpClient .extend ({headers});
19
+
20
+ // subsequent http calls will include an 'Authorization: Bearer 12345' header
15
21
```
16
22
17
- #### Import and initialize a custom Bearer Token client
23
+ #### Disable self-signed TLS/SSL cert checks for development purposes only
18
24
``` js
25
+ import {Agent } from ' https' ;
19
26
import {httpClient } from ' @digitalbazaar/http-client' ;
20
27
21
28
const httpsAgent = new https.Agent ({rejectUnauthorized: false });
22
-
23
- const accessToken = ' 12345' ;
24
- const headers = {Authorization: ` Bearer ${ accessToken} ` };
25
-
26
29
const client = httpClient .extend ({headers, httpsAgent});
27
30
28
- // subsequent http calls will include an 'Authorization: Bearer 12345' header,
29
- // and use the provided httpsAgent
31
+ // subsequent http calls will use the provided httpsAgent
30
32
```
31
33
32
34
#### GET a JSON response in the browser
0 commit comments