Answers for "node check if internet"

0

node check if internet

import dns from 'dns'

const checkInternet = async () => {
  return dns.promises
    .lookup('google.com')
    .then(() => true)
    .catch(() => false)
}

// I used it the following way within an async function:
const internet = await checkInternet()
Posted by: Guest on February-28-2022

Code answers related to "node check if internet"

Code answers related to "Javascript"

Browse Popular Code Answers by Language