Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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()
Comment

PREVIOUS NEXT
Code Example
Javascript :: Minimal Project Angular 
Javascript :: javascript window.onpopstate example 
Javascript :: solo números js 
Javascript :: javascript new date invalid date dd/mm/yyyy 
Javascript :: upgrading to react 18 
Javascript :: convert array object to string javascript 
Javascript :: hasownproperty javascript 
Javascript :: javascript access ajax response headers 
Javascript :: find duplicates in array 
Javascript :: difference between undefined and null javascript 
Javascript :: context api react 
Javascript :: javascript date set hours minutes seconds to 0 
Javascript :: react js alert popup example 
Javascript :: js get browser name and platform 
Javascript :: js history 
Javascript :: difference between package.json and package lock.json 
Javascript :: react router remove location state on refresh 
Javascript :: feet to mile js 
Javascript :: gsap scrolltrigger 
Javascript :: jquery multiple ids same funjquery apply function to multiple elementsction 
Javascript :: change terminal shortcut vscode 
Javascript :: react fragment inside map with key prop 
Javascript :: framer motion nextjs 
Javascript :: serve static files from express 
Javascript :: javascript get cursor position without event 
Javascript :: react router v6 lazy suspense 
Javascript :: javascript array clear 
Javascript :: how to get every index of array in javascript 
Javascript :: try catch javascript 
Javascript :: add an object to an array mongosse 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =