0

I am making an extension to get URL from server and block those

var BlockUrl=[];
function doSomthing(data){
      BlockUrl=data
    }
function loadXMLDoc(){
      $.get('http://localhost:3000/blocker',(data)=>{
          doSomthing(data)
      })
      
    }

loadXMLDoc();
console.log(BlockUrl)
chrome.webRequest.onBeforeRequest.addListener( 
  info => {  
          
          
            return {cancel: true};
          
},
  
  {urls: BlockUrl},
  ["blocking"]
);

But the log is undefined because on asynchronous call. what should I do to resolve it

Rohan Kumar
  • 67
  • 1
  • 11
  • Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – hindmost Aug 19 '20 at 10:14
  • I can't get data because it gives undefined because of asynchronous function. I don't know what to do – Rohan Kumar Aug 20 '20 at 04:13

0 Answers0