you can handel error by try and catch and get fix this error by stackoverflow by this code

        var curnetvlueH1= document.getElementsByTagName('h1')[0]
        let baseContion = false
    
            try {
        if(baseContion){
    
            curnetvlueH1.innerHTML = 'True'
    
    
    
        } 
      
        }
        catch(err) {
            let errostakoverflow = `https:stackoverflow.com/search?q=[js]${err}`
            window.open(errostakoverflow,'_blank')
        }