npm.io
0.1.1 • Published 8 years ago

fluture-axios

Licence
MIT
Version
0.1.1
Deps
0
Size
11 kB
Vulns
0
Weekly
0
Stars
6

fluture-axios

The axios you love, but better because it now returns a fluture.

Installing

Using npm:

$ npm install fluture-axios axios fluture

Note that fluture-axios depends on axios and fluture as peer dependencies.

Example

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.

API

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.

  • See fluture to understand how to work with futures.
  • See axios for more information about working with axios.

Keywords