Lightweight request strategy library
One line of code completes network requests in various complex scenarios. Don’t spend time on the small matter of requesting. Leave it to us.
npm install alova
High performance request strategy
10+ request strategy modules that can be used directly, just choose the one you want to use, and it can also reduce performance problems caused by requests.
Simple and familiar
API design similar to axios, making it easier and more familiar for you to get started
Request-level cache
Provides various server-side data cache modes such as memory mode and persistence mode to improve user experience and reduce server pressure
Lightweight
compressed version is only 4kb+, only 30% of axios
Relationship between alova and request library
Traditional promised request library solves the problem of request sending very well, but They are simply request sending tools
Accomplish your requests in a declarative manner
Just choose the request strategy you want to use, saving your amount of time, and make your application more fluency
- Basic request
- Request when states changed
- Prefetch data
- Pagination request
- Token authentication
- Sensorless data interaction strategy
- Form Submit strategy
- Auto refetch data
- File upload strategy
- Send captcha
- Cross-component request strategy
- Request retry strategy
- SSE
Basic request
Send request with useRequest, it will automatically maintain the states related to this request.
const todoDetail = alova.Get('/todo', {
params: {
id: 1
}
});
const {
loading, data, error,
onSuccess, onError, onComplete,
send, abort, update
} = useRequest(todoDetail);
Runs in any JS environment with any request tool
Use hooks originated from functional components, but alova innovatively made it compatible with options and class-style UI frameworks, which means that alova's use hooks are almost not restricted by JS environments and UI frameworks, and can be used together with your familiar request tools.