So, I have this code
(async function checkPrinterConnection() {
(await window.electronAPI.checkPrinterConnection() == undefined) ?
(document.getElementById('printerIcon').classList.add('printer-icon-error'),
document.getElementById('printerIcon').title = "Impresora sin conexión",
document.getElementById('refreshPrinter').innerHTML = 'Reintentar impresora')
:
(document.getElementById('printerIcon').classList.remove('printer-icon-error'),
document.getElementById('printerIcon').title = "Impresora conectada",
document.getElementById('refreshPrinter').innerHTML = '')
})()
that works well, but when I change it to this one below it returns "Uncaught TypeError: document.getElementById(...) is not a function" and I don't understand why
const printerIcon = document.getElementById('printerIcon')
const refreshPrinter = document.getElementById('refreshPrinter')
(async function checkPrinterConnection() {
(await window.electronAPI.checkPrinterConnection() == undefined) ?
(printerIcon.classList.add('printer-icon-error'),
printerIcon.title = "Impresora sin conexión",
refreshPrinter.innerHTML = 'Reintentar impresora')
:
(printerIcon.classList.remove('printer-icon-error'),
printerIcon.title = "Impresora conectada",
refreshPrinter.innerHTML = '')
})()