Big news!Introducing Socket AI - ChatGPT-Powered Threat Analysis. Learn more
Socket
Log inDemoInstall

@articulate/asyncios

Package Overview
Dependencies
2
Maintainers
35
Versions
2
Issues
File Explorer

Advanced tools

@articulate/asyncios

A wrapper for promise-based library Axios into a crocks Async

    1.0.1latest
    npm

Version published
Maintainers
35
Weekly downloads
525
decreased by-41.14%

Weekly downloads

Readme

Source

asyncios

A crocks Async wrapper for axios. Allows consumers to take advantage of the "lazy" data type while keeping a familiary API.

How to Use

asyncios accepts the same configuration arguments as the underlying axios function. See the axios documentation for more details.

// GET request asyncios({ method: 'GET', url: '/user?ID=12345' }) .fork( error => console.log(error), response => console.log(response) ) // same GET request, but using `params` configuration asyncios({ method: 'GET', url: '/user', params: { ID: 12345 } }) .fork( error => console.log(error), response => console.log(response) ) // POST request asyncios({ method: 'POST', url: '/user?ID=12345', data: { firstName: 'Fred', lastName: 'Flinstone' }, }) .fork( error => console.log(error), response => console.log(response) )

Cancellation

Async-style cancellation is supported. See the crocks doucmentation for more details.

const cancel = asyncios({ method: 'GET', url: '/user?ID=12345' }) .fork( error => console.log(error), response => console.log(response), () => console.log('cancelled!') ) cancel()

axios's cancellation token is also supported. Take note of the different behaviors--while cancelling via crocks will invoke fork's third "cancel" callback, cancelling via axios will invoke fork's first "rejected" callback. See axios's documentation for more details.

const source = axios.CancelToken.source() asyncios({ method: 'GET', url: '/user?ID=12345', cancelToken: source.token }) .fork( error => { if (axios.isCancel(error)) console.log(error.message) else { /* handle error */ } }, response => console.log(response) ) source.cancel('My cancel message')

Thanks

Thanks to the fine people who work on both axios & crocks.

The Name

Pretty sure is spencerfdavis's fault.

FAQs

Last updated on 09 Aug 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc