Skip to main content
100%

legacy pattern by me for async fetching multiple urls

✓ Published0🌍 Public
Aanemochore
Last edited Dec 19, 2019
Created on Dec 19, 2019

This example demonstrates a sequential asynchronous fetching pattern for multiple URLs, showing how to collect and process text responses before triggering a final completion callback. The code uses the raw `XMLHttpRequest` API with an `onreadystatechange` handler to check `readyState` and `status`, then chains the next request by calling `asyncFetch` from within `fetchSuccess`. Each response is truncated to 256 characters and pushed into a global `result` array, with the sequence ending when the URL list is exhausted, as indicated by the `loadEnd` function. The data source is an array of same-origin page URLs, and the rendering is limited to console output of the accumulated results.

AI-generated description

Similar vizzes