@ahoo-wang/fetcher 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +5 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,7 +15,9 @@ A modern HTTP client library based on the Fetch API, designed to simplify and op
15
15
  - **Timeout Settings**: Request timeout can be configured.
16
16
  - **Request Interceptors**: Supports modifying requests before they are sent.
17
17
  - **Response Interceptors**: Supports processing responses after they are returned.
18
+ - **Error Interceptors**: Supports handling errors during the request lifecycle.
18
19
  - **Modular Design**: Clear code structure for easy maintenance and extension.
20
+ - **Automatic Request Body Conversion**: Automatically converts plain objects to JSON and sets appropriate Content-Type headers.
19
21
  - **TypeScript Support**: Complete TypeScript type definitions.
20
22
 
21
23
  ## Installation
@@ -63,11 +65,10 @@ fetcher
63
65
  console.error(error);
64
66
  });
65
67
 
66
- // POST request with JSON body
68
+ // POST request with JSON body (automatically converted to JSON string)
67
69
  fetcher
68
70
  .post('/users', {
69
- body: JSON.stringify({ name: 'John Doe', email: 'john@example.com' }),
70
- headers: { 'Content-Type': 'application/json' },
71
+ body: { name: 'John Doe', email: 'john@example.com' },
71
72
  })
72
73
  .then(response => {
73
74
  console.log(response.data);
@@ -125,7 +126,7 @@ Core HTTP client class that provides various HTTP methods.
125
126
  #### Constructor
126
127
 
127
128
  ```typescript
128
- new Fetcher(options?: FetcherOptions)
129
+ new Fetcher(options: FetcherOptions = defaultOptions)
129
130
  ```
130
131
 
131
132
  **Parameters:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/fetcher",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Core library providing basic HTTP client functionality for Fetcher",
5
5
  "keywords": [
6
6
  "fetch",