@hapaul/api 0.1.8 → 0.1.9

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/dist/index.js +11 -1
  2. package/package.json +1 -4
package/dist/index.js CHANGED
@@ -22,10 +22,12 @@ var Client = class {
22
22
  const headersOptions = requestConfig.headers;
23
23
  const headers = mergeHeaders(headersOptions);
24
24
  const contentType = headers.get("Content-Type");
25
+ const body = requestConfig.body;
25
26
  if (!contentType) headers.set("Content-Type", "application/json");
26
27
  try {
27
- const {} = params;
28
28
  let response = await fetch(url, {
29
+ ...requestConfig,
30
+ body: defaultBodySerializer(body, headers),
29
31
  method: method.toUpperCase(),
30
32
  headers
31
33
  });
@@ -102,6 +104,14 @@ function mergeHeaders(...allHeaders) {
102
104
  }
103
105
  return finalHeaders;
104
106
  }
107
+ function defaultBodySerializer(body, headers) {
108
+ if (body instanceof FormData) return body;
109
+ if (headers) {
110
+ const contentType = headers.get("Content-Type");
111
+ if (contentType === "application/x-www-form-urlencoded") return new URLSearchParams(body).toString();
112
+ }
113
+ return JSON.stringify(body);
114
+ }
105
115
 
106
116
  //#endregion
107
117
  export { Client };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hapaul/api",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -29,8 +29,5 @@
29
29
  "rolldown": "1.0.0-beta.30",
30
30
  "rolldown-plugin-dts": "^0.14.2",
31
31
  "typescript": "^5.8.3"
32
- },
33
- "dependencies": {
34
- "openapi-fetch": "^0.14.0"
35
32
  }
36
33
  }