@molecule/app-http-axios 1.0.4 → 1.0.5
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.
- package/README.md +22 -7
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-10-
|
|
6
|
+
Generated: 2026-10-17T07:40:43.120Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-http-axios
|
|
@@ -13,6 +13,12 @@ Axios HTTP client provider for `@molecule/app-http`.
|
|
|
13
13
|
This package provides an Axios-based implementation of the molecule HttpClient interface,
|
|
14
14
|
allowing you to use molecule's HTTP abstractions with Axios.
|
|
15
15
|
|
|
16
|
+
**The body is the SECOND argument: `post(url, data, config?)` — likewise `put` and `patch`.**
|
|
17
|
+
`data` IS the request body, so `post(url, { data: body })` sends the JSON body
|
|
18
|
+
`{"data":body}`, not `body`, and the API finds none of its fields at the top level (it
|
|
19
|
+
answers `422 {"errors":{"username":["can't be blank"],…}}`). Write `post('/users', { user })`,
|
|
20
|
+
never `post('/users', { data: { user } })`; a config (headers, params) is the THIRD argument.
|
|
21
|
+
|
|
16
22
|
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
17
23
|
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
18
24
|
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
@@ -116,7 +122,8 @@ interface HttpClient {
|
|
|
116
122
|
*/
|
|
117
123
|
defaultHeaders: Record<string, string>
|
|
118
124
|
/**
|
|
119
|
-
* Makes a generic HTTP request.
|
|
125
|
+
* Makes a generic HTTP request. `data` is a field of THIS config object — the same body
|
|
126
|
+
* `post(url, data, config)` takes as its second argument.
|
|
120
127
|
*/
|
|
121
128
|
request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
|
|
122
129
|
/**
|
|
@@ -124,15 +131,19 @@ interface HttpClient {
|
|
|
124
131
|
*/
|
|
125
132
|
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
126
133
|
/**
|
|
127
|
-
* Makes a POST request.
|
|
134
|
+
* Makes a POST request. `data` is the request BODY, not a config object: the wire body is
|
|
135
|
+
* `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
|
|
136
|
+
* A config (headers, params) is the THIRD argument.
|
|
128
137
|
*/
|
|
129
138
|
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
130
139
|
/**
|
|
131
|
-
* Makes a PUT request.
|
|
140
|
+
* Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
141
|
+
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
132
142
|
*/
|
|
133
143
|
put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
134
144
|
/**
|
|
135
|
-
* Makes a PATCH request.
|
|
145
|
+
* Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
146
|
+
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
136
147
|
*/
|
|
137
148
|
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
138
149
|
/**
|
|
@@ -255,7 +266,11 @@ interface RequestConfig {
|
|
|
255
266
|
*/
|
|
256
267
|
signal?: AbortSignal
|
|
257
268
|
/**
|
|
258
|
-
* Request body data
|
|
269
|
+
* Request body data, as a field of THIS config object — the `request({ method, url, data })`
|
|
270
|
+
* form. The verb methods take the body as their SECOND argument: `post(url, data, config)`,
|
|
271
|
+
* `put(url, data, config)`, `patch(url, data, config)`. Never wrap it there as
|
|
272
|
+
* `{ data: body }`: that object is the body, so the wire sends `{"data":body}` and the API
|
|
273
|
+
* sees none of the fields at its top level.
|
|
259
274
|
*/
|
|
260
275
|
data?: unknown
|
|
261
276
|
/**
|
|
@@ -280,7 +295,7 @@ interface FullRequestConfig extends RequestConfig {
|
|
|
280
295
|
*/
|
|
281
296
|
url: string
|
|
282
297
|
/**
|
|
283
|
-
* Request body data.
|
|
298
|
+
* Request body data — a field of this config object, never a second argument here.
|
|
284
299
|
*/
|
|
285
300
|
data?: unknown
|
|
286
301
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* This package provides an Axios-based implementation of the molecule HttpClient interface,
|
|
5
5
|
* allowing you to use molecule's HTTP abstractions with Axios.
|
|
6
6
|
*
|
|
7
|
+
* **The body is the SECOND argument: `post(url, data, config?)` — likewise `put` and `patch`.**
|
|
8
|
+
* `data` IS the request body, so `post(url, { data: body })` sends the JSON body
|
|
9
|
+
* `{"data":body}`, not `body`, and the API finds none of its fields at the top level (it
|
|
10
|
+
* answers `422 {"errors":{"username":["can't be blank"],…}}`). Write `post('/users', { user })`,
|
|
11
|
+
* never `post('/users', { data: { user } })`; a config (headers, params) is the THIRD argument.
|
|
12
|
+
*
|
|
7
13
|
* @module `@molecule/app-http-axios`
|
|
8
14
|
*
|
|
9
15
|
* @example
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* This package provides an Axios-based implementation of the molecule HttpClient interface,
|
|
5
5
|
* allowing you to use molecule's HTTP abstractions with Axios.
|
|
6
6
|
*
|
|
7
|
+
* **The body is the SECOND argument: `post(url, data, config?)` — likewise `put` and `patch`.**
|
|
8
|
+
* `data` IS the request body, so `post(url, { data: body })` sends the JSON body
|
|
9
|
+
* `{"data":body}`, not `body`, and the API finds none of its fields at the top level (it
|
|
10
|
+
* answers `422 {"errors":{"username":["can't be blank"],…}}`). Write `post('/users', { user })`,
|
|
11
|
+
* never `post('/users', { data: { user } })`; a config (headers, params) is the THIRD argument.
|
|
12
|
+
*
|
|
7
13
|
* @module `@molecule/app-http-axios`
|
|
8
14
|
*
|
|
9
15
|
* @example
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|