Uncaught TypeError: Cannot read properties of undefined (reading ‘query’) at HTMLButtonElement

I was using function chrome.tabs.query of chrome and I got this error Uncaught TypeError: Cannot read properties of undefined (reading ‘query’) at HTMLButtonElement

function saveTab() {
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
        myLeads.push(tabs[0].url)
        localStorage.setItem("myLeads", JSON.stringify(myLeads) )
        render(myLeads)
    })
}