1function download(url, filename) {
2fetch(url).then(function(t) {
3 return t.blob().then((b)=>{
4 var a = document.createElement("a");
5 a.href = URL.createObjectURL(b);
6 a.setAttribute("download", filename);
7 a.click();
8 }
9 );
10});
11}
12
13download("https://get.geojs.io/v1/ip/geo.json","geoip.json")
14download("data:text/html,HelloWorld!", "helloWorld.txt");