- Notifications
You must be signed in to change notification settings - Fork0
License
articulate/asyncios
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Acrocks Async wrapper foraxios. Allows consumers to take advantage of the "lazy" data type while keeping a familiar API.
asyncios accepts the same configuration arguments as the underlying axios function.See the axios documentation for more details.
// GET requestasyncios({method:'GET',url:'/user?ID=12345'}).fork(error=>console.log(error),response=>console.log(response))
// same GET request, but using `params` configurationasyncios({method:'GET',url:'/user',params:{ID:12345}}).fork(error=>console.log(error),response=>console.log(response))
// POST requestasyncios({method:'POST',url:'/user?ID=12345',data:{firstName:'Fred',lastName:'Flinstone'},}).fork(error=>console.log(error),response=>console.log(response))
Async-style cancellation is supported. See thecrocks doucmentation for more details.
constcancel=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 invokefork's third "cancel" callback, cancelling via axios will invokefork's first "rejected" callback.See axios's documentation for more details.
constsource=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 to the fine people who work on bothaxios &crocks.
Pretty sure isspencerfdavis's fault.
About
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.