payload-plugin-newsletter 0.25.5 → 0.25.6

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.
@@ -207,6 +207,7 @@ var init_broadcast2 = __esm({
207
207
  }
208
208
  async get(id) {
209
209
  try {
210
+ console.log("[BroadcastApiProvider] Getting broadcast with ID:", id);
210
211
  const response = await fetch(`${this.apiUrl}/api/v1/broadcasts/${id}`, {
211
212
  method: "GET",
212
213
  headers: {
@@ -281,7 +282,18 @@ var init_broadcast2 = __esm({
281
282
  }
282
283
  throw new Error(`Broadcast API error: ${response.status} - ${errorText}`);
283
284
  }
284
- const result = await response.json();
285
+ const responseText = await response.text();
286
+ console.log("[BroadcastApiProvider] Success response body:", responseText);
287
+ let result;
288
+ try {
289
+ result = JSON.parse(responseText);
290
+ } catch (e) {
291
+ throw new Error(`Failed to parse response as JSON: ${responseText}`);
292
+ }
293
+ console.log("[BroadcastApiProvider] Parsed result:", result);
294
+ if (!result.id) {
295
+ throw new Error(`Response missing expected 'id' field: ${JSON.stringify(result)}`);
296
+ }
285
297
  return this.get(result.id.toString());
286
298
  } catch (error) {
287
299
  if (error instanceof BroadcastProviderError) throw error;
@@ -2337,7 +2349,18 @@ var createBroadcastsCollection = (pluginConfig) => {
2337
2349
  providerData: providerBroadcast.providerData
2338
2350
  };
2339
2351
  } catch (error) {
2340
- req.payload.logger.error("Failed to create broadcast in provider during initial creation:", error);
2352
+ req.payload.logger.error("Failed to create broadcast in provider during initial creation:");
2353
+ if (error instanceof Error) {
2354
+ req.payload.logger.error("Error details:", {
2355
+ message: error.message,
2356
+ stack: error.stack,
2357
+ name: error.name,
2358
+ // Check for any additional properties
2359
+ ...error
2360
+ });
2361
+ } else {
2362
+ req.payload.logger.error("Raw error:", error);
2363
+ }
2341
2364
  return doc;
2342
2365
  }
2343
2366
  }