Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

articulate/asyncios

Repository files navigation

Acrocks Async wrapper foraxios. Allows consumers to take advantage of the "lazy" data type while keeping a familiar API.

How to Use

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))

Cancellation

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

Thanks to the fine people who work on bothaxios &crocks.

The Name

Pretty sure isspencerfdavis's fault.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp