got network error always. anyone can help? thanks!
Could you link to an example notebook that illustrates the issue?
As I understand it, thereâs less of a reason to use Axios now that the Fetch standard is supported by modern browsers. Perhaps you are running into CORS issues? Have you read the introduction to data notebook?
I need data from remote js file, like this âhttp://lol.qq.com/biz/hero/champion.jsâ, I want to load it directly instead of saving it to local. Sorry, I am a new developer, maybe there is better way to implement.
Sounds like you need a CORS proxy. You canât fetch directly from an HTTP site (HTTPS is required) and the server must have CORS enabled. You can try the demo instance of CORS-Anywhere to start.
For what itâs worth, I tried to use a few different CORS proxies to load your data, but without success:
I couldnât get CORS-anywhere to work at all. The other two proxies send the JS file with the wrong MIME Content-type: cors.io sends it as text/html
and codetabs sends it as text/plain
.
This might be a bit confusing at first because the file isnât data - itâs JavaScript code. So solving CORS, using axios, and other steps arenât directionally right. You can, however, achieve what you want to do:
require("https://lol.qq.com/biz/hero/champion.js").catch(() => window.LOLherojs)
This uses require()
, our method for including code, but since champion.js
doesnât implement UMD or any sort of âmodule definitionâ standard and instead just leaves a variable behind, we catch that variable (what I call the âglobal leaks patternâ in the module debugger).
(The other minor quirk is that I changed the URL from http://
to https://
. qq.com supports both, but http:// wonât work with Observable or any SSL website).
Thanks for your time!
Thanks!
It works!!! Really appreciate!