20

I have this code:

chrome.webRequest.onCompleted.addListener(function(details){
  console.log(details);
});

I'm trying to understand and use the chrome.webRequest API. I can't figure why the code isn't working, I just wanna give a try to the API by logging all the requests made by chrome. I've set the permissions in my manifest on these two patterns http://*/* and https://*/* but i will always get this error from my background script: Uncaught TypeError: No matching signature. Any help is appreciated.

Community
  • 1
  • 1
jihuuNI
  • 551
  • 2
  • 5
  • 17

1 Answers1

38

"No matching signature" means you're passing the wrong parameters. As you can see in the documentation's concepts and examples you need to specify at least two parameters. The documentation for individual methods doesn't mention that which is really confusing, and you can report it on https://crbug.com.

chrome.webRequest.onCompleted.addListener(
  function(details) {
    console.log(details);
  },
  {urls: ["<all_urls>"]}
);

To view the background script's console see this answer.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136
  • Yes, I was reading the method documentation and it's not specified that the callback take two params. Thank you. – jihuuNI Sep 01 '19 at 15:02
  • 1
    It is documented here: http://chrome-apps-doc2.appspot.com/extensions/webRequest.html#subscription – noam Jan 11 '20 at 19:51
  • @noam, the answer already has the correct documentation links. – wOxxOm Jan 12 '20 at 04:07