
Security News
Inside Lodash’s Security Reset and Maintenance Reboot
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.
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.
The npm package request-state-wrapper receives a total of 1 weekly downloads. As such, request-state-wrapper popularity was classified as not popular.
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
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.

Security News
n8n led JavaScript Rising Stars 2025 by a wide margin, with workflow platforms seeing the largest growth across categories.

Security News
The U.S. government is rolling back software supply chain mandates, shifting from mandatory SBOMs and attestations to a risk-based approach.