Skip to content

Commit 1cbb942

Browse files
committed
fix: client now appends instead of overwrites response data
- Changed displayResponse to use += instead of = for appending - Added clear response content on new connection for fresh start - Now all weather data sections will be visible: connection, location, current weather, forecast, alerts - Each SSE message will append to the display instead of overwriting
1 parent 1ea1aaf commit 1cbb942

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/sse_client_real.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ <h2>📝 Real-Time Logs</h2>
253253
document.getElementById('connectBtn').disabled = true;
254254
document.getElementById('disconnectBtn').disabled = false;
255255

256+
// Clear previous response data for fresh start
257+
const responseContent = document.getElementById('responseContent');
258+
responseContent.textContent = '';
259+
256260
const connectionInfo = document.getElementById('connectionInfo');
257261
const connectionDetails = document.getElementById('connectionDetails');
258262
connectionInfo.style.display = 'block';
@@ -362,10 +366,12 @@ <h2>📝 Real-Time Logs</h2>
362366
try {
363367
// Try to parse and pretty-print JSON
364368
const parsed = typeof data === 'string' ? JSON.parse(data) : data;
365-
responseContent.textContent = `=== ${title} ===\n${JSON.stringify(parsed, null, 2)}`;
369+
const newContent = `=== ${title} ===\n${JSON.stringify(parsed, null, 2)}\n\n`;
370+
responseContent.textContent += newContent; // APPEND instead of overwrite
366371
} catch (e) {
367372
// If not JSON, display as-is
368-
responseContent.textContent = `=== ${title} ===\n${data}`;
373+
const newContent = `=== ${title} ===\n${data}\n\n`;
374+
responseContent.textContent += newContent; // APPEND instead of overwrite
369375
}
370376

371377
responseDisplay.style.display = 'block';

0 commit comments

Comments
 (0)