How can I get return value

I am trying to get tab return value But it does not pass

// backround.js

 alert (getTabIndex())
   function getTabIndex() {  
     chrome.tabs.query({active: true, currentWindow: true},  function(tabs) {
     var tab = tabs[0].index;
     return tab

Looking at the documentation it appears that chrome.tabs.query returns a Promise, so you’ll need to take that into account. Also, you are just calling the method, you aren’t actually saving the return value.

So, how can I get ‘tab’ value?

Did you look at the example in the docs I linked to? I’m guessing you should do something similar to that. I’ve never played with this particular API but the example they had seemed pretty clear.

I get an error

Error in event handler: TypeError: Error in invocation of tabs.query(object queryInfo, function callback): No matching signature.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.