Skip to content

maxchou415/Callback-vs-AsyncFunction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Callback vs Async Function

Please DO NOT run this project, this is a example project.

#Callback

(exampleFunction () => {
  A.find({}, (err, aData) => {
    if(err) console.log(err)
    B.find({}, (err, bData) => {
      if(err) console.log(err)
      C.find({}, (err, cData) {
        if(err) console.log(err)
        console.log('A', aData)
        console.log('B', bData)
        console.log('C', cData)
      })
    })
  })
})

#Async Function

(async () => {
  try {
    let A = await A.find({})
    let B = await B.find({})
    let C = await C.find({})

    console.log('A', A)
    console.log('B', B)
    console.log('C', C)
  } catch(e) {
    console.log(e)
  }
})

About

Please DO NOT run this project, this is a example project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published