Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch API cannot load #23

Open
cr0wg4n opened this issue Aug 28, 2021 · 5 comments
Open

Fetch API cannot load #23

cr0wg4n opened this issue Aug 28, 2021 · 5 comments

Comments

@cr0wg4n
Copy link

cr0wg4n commented Aug 28, 2021

Chrome console output:

Fetch API cannot load file:///home/XXXXXX/Desktop/Proyecto%20Final/proyecto-final-hardware/demo/spec.json. URL scheme "file" is not supported.

I think you use the spec.json file as a file structure it's great but recently when I try this library the browsers (firefox and chrome) have the same problem, it is a normal beahviur or maybe I wrong?.

That's my template.html script configuration:

  <script>
      pinion.setup(document.getElementById("root"), {
          source: "."
      });
  </script>

Thanks and nice library :D.

@cr0wg4n
Copy link
Author

cr0wg4n commented Aug 28, 2021

I read your code and I use the serve command, then all works well hahaha, the FAQ section coves that part, but I think is a relevant piece for your main explanation, thanks a lot, you help me to make a well documented project :D

@yaqwsx
Copy link
Owner

yaqwsx commented Aug 28, 2021

I hoped that https://yaqwsx.github.io/Pinion/diagramWalkthrough/#testing-the-diagram covers it. Do you have a proposal for reasonable improvement?

@cr0wg4n
Copy link
Author

cr0wg4n commented Aug 28, 2021

Oh well I don't read that part (I mean the testing part confuse me with testing like test files and coverage you know), that's my fault, but if I could make some improvement to avoid the browsers behaviur I suggest to embed the spec.json file inside the js file or optionally create the spec.json in a javascript file as a json variable that the pinion.js could recover it properlly througth the HTML importation, it's something ugly but it could be work without any server, with this feature the HTML site will be cross-platform (actually I need the pinion cli for serve the site as http server)

@yaqwsx
Copy link
Owner

yaqwsx commented Aug 28, 2021

Embedding the JSON file might be an option easy to add but it does not solve the problem with cross-origin image fetching.

@cr0wg4n
Copy link
Author

cr0wg4n commented Aug 28, 2021

The image fetching will be still working well, you're using the img HTML element for image fetching, the problem is at the spec.json file, you're using the fetch API, fetch always works well using a http server, but if you can run as a simple html.. fetch not works, embedding I think is an interesting solution, if you want expose the spec.json for no obfuscation reasons, you can use it as a javascript file and loading before pinion.js in your template.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants