You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-28Lines changed: 90 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@
11
11
<palign="center">
12
12
<ahref="#about">About</a> •
13
13
<ahref="#disclaimer">Disclaimer</a> •
14
-
<ahref="#install">Install</a> •
14
+
<ahref="#getting-started">Getting Started</a> •
15
15
<ahref="#how-to-use">How To Use</a>
16
16
</p>
17
17
<palign="center">
@@ -30,9 +30,15 @@ HTTP Client is an expressive, minimal wrapper around the [Fetch()](https://devel
30
30
31
31
Until HTTP Client reaches a 1.0.0 release, breaking changes will be released with a new minor version.
32
32
33
-
## Install
33
+
## Getting Started
34
34
35
-
You can install HTTP Client from npm registry and GitHub Packages.
35
+
You will need to make sure your system meets the following prerequisites:
36
+
37
+
- Node.js >= 18.0.0
38
+
39
+
#### Package installation
40
+
41
+
You can install HTTP Client from npm registry or GitHub Packages.
36
42
37
43
```shell
38
44
npm install @wolfpackthatcodes/http-client
@@ -44,7 +50,10 @@ To install HTTP Client from GitHub Packages, follow the steps in the GitHub docu
44
50
45
51
This project is a work-in-progress. Code and documentation are currently under development and are subject to change.
46
52
47
-
#### Making requests
53
+
Documentation on the available functionality has been outlined below for you to get started:
54
+
55
+
<details>
56
+
<summary><b>1. Making requests</b></summary>
48
57
49
58
Since the HTTP Client is a wrapper for Fetch() API, you can still make `HEAD`, `GET`, `POST`, `PUT`, `PATCH`, `DELETE` requests using the respectively helper methods provided.
50
59
@@ -91,7 +100,10 @@ const response = new HttpClient()
91
100
.get('https://api.example.local/users');
92
101
```
93
102
94
-
#### Send request with data
103
+
</details>
104
+
105
+
<details>
106
+
<summary><b>2. Sending request with data</b></summary>
95
107
96
108
You can send additional data with your `POST`, `PUT`, and `PATCH` requests. These methods accept either a string or an object of data as their second argument.
97
109
@@ -102,7 +114,7 @@ const response = new HttpClient()
You can add multiple headers to the request by using the `withHeaders` method. The `withHeaders` method accepts an object of key / value pairs:
157
+
<details>
158
+
<summary><b>3. Include headers</b></summary>
159
+
160
+
You can add multiple headers to the request by using the `withHeaders` method. The `withHeaders` method accepts an object of key / value pairs or Headers instance:
@@ -167,16 +188,25 @@ const response = new HttpClient()
167
188
168
189
##### Replace headers
169
190
170
-
The `replaceHeaders` method allow you to replace multiple headers. The `replaceHeaders` method accepts an object of key / value pairs:
191
+
The `replaceHeaders` method allow you to replace multiple headers. The `replaceHeaders` method accepts an object of key / value pairs or Headers instance:
<summary><b>5. Include Fetch options</b></summary>
275
+
276
+
You may specify additional Fetch() API [Request options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) using the `withOptions` method. The `withOptions` method accepts an object of key / value pairs:
The HTTP Client offers a `fake` method that allows you to instruct the HTTP Client to return mocked responses when requests are made.
301
+
<details>
302
+
<summary><b>6. Testing</b></summary>
303
+
304
+
The HTTP Client offers a `fake` method that allows you to instruct the HTTP Client to return mocked responses when requests are made. The `fake` method will prevent the HTTP Client to make a HTTP request.
@@ -274,6 +334,8 @@ const response = new HttpClient()
274
334
.get('https://api.example.local/users');
275
335
```
276
336
337
+
</details>
338
+
277
339
## Changelog
278
340
279
341
Please see [CHANGELOG](https://github.com/wolfpackthatcodes/typescript-http-client/blob/main/CHANGELOG.md) for more information on what has changed recently.
0 commit comments