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!