I am trying to handle the chrome.tabs.query
to return tab id.
function getTabID () {
var tabID = ''
chrome.tabs.query({
active: true,
}, function(tabs) {
tabsID = tabs[0].id
}
return tabID
}
And i am trying to get the tabID. It seems chrome.tabs.query({
is a async method.
var responseTabID = getTabID() //calling the getTabID method.
// Code using responseTabID
So here i need to wait for the getTabID method to return the tabID. so that i am going to use that tabID further.
I can even call a method inside function(tabs) { // calling a method here }
. But i need the tabID in multiple places, so i just wanted to implement a new method to return the tabID.
How to wait for the getTabID method? is it possible to using async/await?