@hapaul/api 0.1.16 → 0.1.17

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/dist/index.d.ts CHANGED
@@ -1422,7 +1422,7 @@ type ResponseError<T extends PathsWithMethod<paths, M>, M extends Methods> = Err
1422
1422
  type ClientConfig = {
1423
1423
  baseUrl?: string;
1424
1424
  fetch?: typeof fetch;
1425
- bodySerializer?: (data: any, headers: Headers) => any;
1425
+ bodySerializer?: (data: any, headers: Headers) => Promise<any> | any;
1426
1426
  };
1427
1427
  type RequestConfig<T extends PathsWithMethod<paths, M>, M extends Methods, C = {}> = ClientConfig & {
1428
1428
  method: M;
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var Client = class {
31
31
  const body = requestConfig.body;
32
32
  if (!contentType) headers.set("Content-Type", "application/json");
33
33
  try {
34
- const serializedBody = this.bodySerializer(body, headers);
34
+ const serializedBody = await this.bodySerializer(body, headers);
35
35
  let response = await this.fetch(url, {
36
36
  ...requestConfig,
37
37
  body: serializedBody,
@@ -113,7 +113,7 @@ function mergeHeaders(...allHeaders) {
113
113
  function defaultQuerySerializer(query) {
114
114
  return new URLSearchParams(query).toString();
115
115
  }
116
- function defaultBodySerializer(body, headers) {
116
+ async function defaultBodySerializer(body, headers) {
117
117
  if (body instanceof FormData) return body;
118
118
  if (headers) {
119
119
  const contentType = headers.get("Content-Type");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hapaul/api",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [