@greatapps/common 1.1.88 → 1.1.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/common",
3
- "version": "1.1.88",
3
+ "version": "1.1.90",
4
4
  "description": "Shared library for GreatApps frontend applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./src/index.ts",
@@ -25,16 +25,19 @@ class ApiClient {
25
25
  return url;
26
26
  }
27
27
 
28
- private async getDefaultHeaders(token: string): Promise<HeadersInit> {
28
+ private async getDefaultHeaders(token: string, isFormData = false): Promise<HeadersInit> {
29
29
  console.log('[ApiClient] getDefaultHeaders', {
30
30
  token: token.substring(0, 20) + '...',
31
31
  });
32
32
 
33
33
  const headers: HeadersInit = {
34
- 'Content-Type': 'application/json',
35
34
  authorization: token,
36
35
  };
37
36
 
37
+ if (!isFormData) {
38
+ headers['Content-Type'] = 'application/json';
39
+ }
40
+
38
41
  return headers;
39
42
  }
40
43
 
@@ -53,7 +56,7 @@ class ApiClient {
53
56
 
54
57
  const [url, defaultHeaders] = await Promise.all([
55
58
  this.buildUrl(endpoint, id),
56
- this.getDefaultHeaders(token),
59
+ this.getDefaultHeaders(token, fetchConfig.body instanceof FormData),
57
60
  ]);
58
61
 
59
62
  console.log('[ApiClient] Fetching', {
@@ -118,6 +121,10 @@ class ApiClient {
118
121
  });
119
122
  }
120
123
 
124
+ async postFormData<T>(endpoint: string, data: FormData, config?: RequestConfig): Promise<T> {
125
+ return this.request<T>(endpoint, { ...config, method: 'POST', body: data });
126
+ }
127
+
121
128
  async put<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<T> {
122
129
  return this.request<T>(endpoint, {
123
130
  ...config,