Skip to content

suissa/try-await

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

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

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 )

About

My tryAwait module for async/await use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published