vendredi 18 septembre 2020

Can't fetch files from my local directory with fetch() API in javascript

I cant fetch files from my local directory ::

  async function getData() {
    const response = await fetch("dina.png");
    const data = await response.blob();
    document.querySelector("img").src = URL.createObjectURL(data);
  }
  getData();

ERRORS

ERROR : cannot load - file path - . URL scheme must be "http" or "https" for CORS request. getData @ file.html:12 (anonymous) @ file.html:16. ERROR : Uncaught (in promise) TypeError: Failed to fetch at getData (file.html:12)enter code here at file.html:16




Aucun commentaire:

Enregistrer un commentaire