Skip to content

Commit 884d83a

Browse files
Copilothotlong
andcommitted
Changes before error encountered
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 08a76e9 commit 884d83a

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

examples/browser/index.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ <h2 style="margin-top: 30px;">📄 Results</h2>
269269
// The @objectql/sdk package automatically includes a polyfill for older browsers!
270270

271271
// Simple DataApiClient implementation for demo
272+
// This includes the same polyfill approach as the real SDK
273+
274+
// Helper function to create timeout signal with fallback
275+
function createTimeoutSignal(ms) {
276+
if (typeof AbortSignal !== 'undefined' && AbortSignal.timeout) {
277+
return AbortSignal.timeout(ms);
278+
}
279+
// Fallback for older browsers
280+
const controller = new AbortController();
281+
setTimeout(() => controller.abort(), ms);
282+
return controller.signal;
283+
}
284+
272285
class DataApiClient {
273286
constructor(config) {
274287
this.baseUrl = config.baseUrl.replace(/\/$/, '');
@@ -301,7 +314,7 @@ <h2 style="margin-top: 30px;">📄 Results</h2>
301314
method,
302315
headers,
303316
body: body ? JSON.stringify(body) : undefined,
304-
signal: AbortSignal.timeout(this.timeout)
317+
signal: createTimeoutSignal(this.timeout)
305318
});
306319

307320
return await response.json();
@@ -345,7 +358,7 @@ <h2 style="margin-top: 30px;">📄 Results</h2>
345358
const response = await fetch(`${this.baseUrl}${path}`, {
346359
method,
347360
headers,
348-
signal: AbortSignal.timeout(this.timeout)
361+
signal: createTimeoutSignal(this.timeout)
349362
});
350363

351364
return await response.json();

0 commit comments

Comments
 (0)