我正在使用fetch API调用API从服务器下载Excel文件,但它没有强制浏览器进行下载,以下是我的头部响应:
HTTP/1.1 200 OK Content-Length: 168667
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Server: Microsoft-IIS/8.5
Content-Disposition: attachment; filename=test.xlsx
Access-Control-Allow-Origin: http://localhost:9000
Access-Control-Allow-Credentials: true
Access-Control-Request-Method: POST,GET,PUT,DELETE,OPTIONS
Access-Control-Allow-Headers: X-Requested-With,Accept,Content-Type,Origin
Persistent-Auth: true
X-Powered-By: ASP.NET
Date: Wed, 24 May 2017 20:18:04 GMT
以下是我用来调用API的代码:
this.httpClient.fetch(url, {
method: 'POST',
body: JSON.stringify(object),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})