
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
request-state-wrapper
Advanced tools
A simple wrapper for Asynchronous JavaScript requests that allows you to detect stalled, fetching and finished states.
What is the point of this tool? Read Better loading states for the modern web.
import { createRequest } from 'request-state-wrapper';
// Create your smart request
const request = createRequest({
request: [<Promise>], // Array of Promises
stalledDelay: Number, // Time in MS before we consider a request stalled
onStateChange: Function, // Callback executed every time request state changes
});
// run it!
request();
// Before
// Set our loading state
loading = true
// Start our asyncronous request/s
Promise.all([asyncRequest(), anotherAsyncRequest()]).then(payload => {
// When it's finished, set loading state to false
loading = false
// Then handle the response
if(payload.error) // show error screen
// show success screen
});
// After
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest, anotherAsyncRequest],
stalledDelay: 250,
onStateChange: state => { ... },
})
getData().then(payload => console.log(payload));
With async/await
// Before
async function requests () {
const payload = await Promise.all[asyncRequest(), anotherAsyncRequest()];
console.log(payload);
}
// After
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest, anotherAsyncRequest],
stalledDelay: 250,
onStateChange: state => { ... },
})
const data = await getData();
Add a specific handler for each type of event:
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest(), anotherAsyncRequest()],
stalledDelay: 250,
onFetching: state => { ... },
onStalled: state => { ... },
onFinished: state => { ... },
})
Note, specific handler will override onStateChange().
Create your request, and add/override handlers when you run the request:
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest(), anotherAsyncRequest()],
stalledDelay: 250,
})
const data = await getData({ onStateChange: state => { ... } });
Want some more examples? Check out some demo recipes:
Simple UI with React Simple UI with React Hooks NodeJS server
FAQs
A tiny package for managing the state of asynchronous requests.
We found that request-state-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.