@reevit/react 0.2.3 → 0.2.4

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.mjs CHANGED
@@ -107,15 +107,19 @@ var ReevitAPIClient = class {
107
107
  async request(method, path, body) {
108
108
  const controller = new AbortController();
109
109
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
110
+ const headers = {
111
+ "Content-Type": "application/json",
112
+ "X-Reevit-Key": this.publicKey,
113
+ "X-Reevit-Client": "@reevit/react",
114
+ "X-Reevit-Client-Version": "0.2.3"
115
+ };
116
+ if (method === "POST" || method === "PATCH" || method === "PUT") {
117
+ headers["Idempotency-Key"] = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
118
+ }
110
119
  try {
111
120
  const response = await fetch(`${this.baseUrl}${path}`, {
112
121
  method,
113
- headers: {
114
- "Content-Type": "application/json",
115
- "Authorization": `Bearer ${this.publicKey}`,
116
- "X-Reevit-Client": "@reevit/react",
117
- "X-Reevit-Client-Version": "1.0.0"
118
- },
122
+ headers,
119
123
  body: body ? JSON.stringify(body) : void 0,
120
124
  signal: controller.signal
121
125
  });