JSFiddle - React, Tailwind, and code Playground

by denisz

JavaScript

const asyncAxios = async () => {
   throw Error('Some error inside async function')
}


const checkAuth = async () => {
  try {
    const response = await asyncAxios('Error123')
    console.log('1123')
  } catch (error) {
    // This line catches all errors in `try`block. It aslo catches errors inside async functions in case you use `await` 
    console.log('Something went wrong', error.message)
  }
}

checkAuth().catch((error) => {
	console.log('Catch section outside the function', error.message)
})