@@ -3,30 +3,32 @@ An opinionated, isomorphic HTTP client for Node.js, browsers, and React Native.
33
44### Usage
55
6- #### Import httpClient (Node.js)
6+ #### Import httpClient (Node.js, browsers, or React Native )
77``` js
8- import https from ' https' ;
98import {httpClient } from ' @digitalbazaar/http-client' ;
109```
1110
12- #### Import httpClient (browsers or React Native)
11+ #### Import and initialize a custom Bearer Token client
1312``` js
1413import {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
1521```
1622
17- #### Import and initialize a custom Bearer Token client
23+ #### Disable self-signed TLS/SSL cert checks for development purposes only
1824``` js
25+ import {Agent } from ' https' ;
1926import {httpClient } from ' @digitalbazaar/http-client' ;
2027
2128const httpsAgent = new https.Agent ({rejectUnauthorized: false });
22-
23- const accessToken = ' 12345' ;
24- const headers = {Authorization: ` Bearer ${ accessToken} ` };
25-
2629const client = httpClient .extend ({headers, httpsAgent});
2730
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
3032```
3133
3234#### GET a JSON response in the browser
0 commit comments