Hi all, I need some help with a chrome extension I am working on.
In the following function I am attempting to make an API request and then pass the response into a function that replaces HTML elements with the API response on a certain website. I know the API call returns the correct data because I tested that before attempting to return the data in the fetchAndReplace() function. I also know the fetchAndReplace() function correctly changes HTML elements when values are hardcoded in.
https://showbox.tools/
However when trying to combine the two, nothing happens on the website I am trying to affect. I have no idea why since both work independently. Could it be that the page loads before the request can be completed and therefore the return function is never executed? Any help is appreciated.
async function makeRequest() {
try {
const response = await fetch('PERSONAL_API_KEY');
const json = await response.json()
return fetchAndReplace(json);
} catch (err) {
return console.log(err);
}
}