0

Javascript Fetch API not loading in Firefox Extension. I am quiet new here, but how do I solve the problem or what alternatives do I have to get a file from the server in Browser Extensions?

test.html

<!DOCTYPE html>
<html>
<body>
<p id="demo">Fetch a file to change this text.</p>
<script>


fetch ('http://localhost/test/test.txt')
.then(x => x.text())
.then(y => document.getElementById("demo").innerHTML = y);

</script>
</body>
</html>

manifest.json

{

  "manifest_version": 2,
  "name": "test",
  "version": "1",

  "description": "test",  

  "permissions": [
    "storage",
    "activeTab",
     "tabs",
     "http://*/*",
    "https://*/*"
  ],
  
  "browser_action": {
   
    "default_title": "test",
    "default_popup": "popup/test.html"
  }
}
MakiWolf
  • 1
  • 1
  • 3
  • Use a separate js file, not an inline script. – wOxxOm Dec 19 '20 at 10:11
  • Note that the popup is a separate window so it has its own separate devtools: right-click inside the popup and select "inspect" in the menu. In Firefox it's [slightly more complicated](https://extensionworkshop.com/documentation/develop/debugging/). – wOxxOm Dec 19 '20 at 10:13
  • Thanks a lot. That solved the problem. – MakiWolf Dec 19 '20 at 10:23

0 Answers0