I’ve been trying to adopt async/await as much as possible, but the following async function fails with the error message:
Here is the code content in search_results.js:
const logToConsole = true;
(function(){
if (logToConsole) console.log(`Requesting search results..`);
requestSearchResults();
}())
async function requestSearchResults(){
try {
let response = await browser.runtime.sendMessage({action: "returnSearchResults"});
handleResponse(response);
} catch (err) {
if (logToConsole) {
console.error(err);
console.log("Failed to retrieve search results.");
}
}
}
function handleResponse(content) {
if (logToConsole) console.log(content);
if (content === undefined || content === null || content === "") return;
let results = document.getElementById("results");
let doc = results.contentWindow.document;
let h = window.innerHeight + "px";
results.style.height = h;
doc.open();
doc.write(content);
doc.close();
}