The axios you love, but better because it now returns a fluture.
Using npm:
$ npm install fluture-axios axios fluture
Note that fluture-axios depends on axios and fluture as peer dependencies.
Performing a GET
request
// Create a future request for a user with a given ID
const userFuture = fluaxios.get('/user?ID=12345')
const cancel = userFuture.fork(console.error, console.log)
Note that cancel
can be invoked to cancel the request in flight as an abstraction over axios's cancellation.
Fluture-axios current supports the following methods from axios:
- fluaxios#request(config)
- fluaxios#get(url[, config])
- fluaxios#delete(url[, config])
- fluaxios#head(url[, config])
- fluaxios#options(url[, config])
- fluaxios#post(url[, data[, config]])
- fluaxios#put(url[, data[, config]])
- fluaxios#patch(url[, data[, config]])
The above methods will return a future for the request and once forked, will return a cancellation function.