I am working on a Chrome extension and the function for the active tab URL is returning an undefined value, although the inner console log is showing the URL
PS: I am a noob in terms of Javascript
function tabURL()
{
var tabUrl;
chrome.tabs.query({currentWindow: true,active: true}, function(tabs) {
tabUrl = tabs[0].url;
console.log(tabUrl); //Showing the right URL
});
console.log(tabUrl); //Showing undefined
return tabUrl;
}
I expect the activeTab URL but the actual output is undefined