Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
async function* paginate(url) { let page = 1, hasMore = true; while (hasMore) { const { data, next } = await fetch(`${url}?page=${page}`).then(r => r.json()); yield data; hasMore = !!next; page++; } } for await (const batch of paginate("/api/items")) { processBatch(batch); }
Result
Open