0
如何從抓取URL下載所需的JSON?如何在JavaScript中使用Fetch下載Json?
下載地址是XLSX。
CODE
function teste(){
alert(fetch ("url")
.then(response => response.json())
.then(data => { console.log(data)})
.then(response => response.blob())
.then(blob => {
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = "filename.xlsx";
a.click();
})
)
}
'alert()'的目的是什麼?沒有值從第二個'.then()'返回。' – guest271314
首先,第一個'.then()'不會傳播數據'這意味着第二個'.then()'''response'是'未定義'。 – zero298
對於做一個測試,我不知道它是否是正確的形式。 – Jota