0

I have the following block of code

function findLastEpisodeLink_helper(title) {

  var url;

  chrome.history.search(
   {
    'text': title,
    'maxResults': 1,
    'startTime': 0
   },

  function(historyItems) {

    url = historyItems[0]["url"];
    // console.log(url);
  }

  );
  // console.log(url);
  return url;
}

Whenever i use this function it returns undefined, I found that its because this is a asyncronous call.

Can someone help me fix this code similar solution dont seems to work.

Swastik Singh
  • 181
  • 1
  • 1
  • 9
  • 1
    if you are sure it is an async call add `await` keyword before `chrome.history.search(` – Yadu Aug 28 '20 at 09:06
  • It's not async. It uses an asynchronous callback. See the linked topic for examples of using asynchronous callbacks correctly. – wOxxOm Aug 28 '20 at 11:56

0 Answers0