Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suissa/try-await
My tryAwait module for async/await use.
https://github.com/suissa/try-await
Last synced: 6 days ago
JSON representation
My tryAwait module for async/await use.
- Host: GitHub
- URL: https://github.com/suissa/try-await
- Owner: suissa
- Created: 2018-02-20T20:13:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-20T20:23:03.000Z (almost 7 years ago)
- Last Synced: 2024-10-30T01:45:27.556Z (about 2 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# try-await - tryAwait - module
I created this atomic module to help me work more cleanly with the async/await flow.
Article explaining how I did this in pt-br: https://medium.com/@osuissa/javascript-encapsulando-o-try-catch-do-async-await-fabb73392189
## Example
```js
const axios = require('axios')
const tryAwait = require('try-await')const URL = 'https://reqres.in/api/users/'
const cbTry = (res) => console.log('Sucesso: ', res.data)
const cbCatch = (err) => console.log('ERROOO: ', err)const callback = ({
try: cbTry
, catch: cbCatch
})const getUser = (user) => axios({ method: 'get', url: URL + user })
tryAwait( getUser(2), callback )
```