通过lambda和API网关从S3下载PDF在Postman上工作,但在Nodejs Axios中失败,带有Chrome错误 - 失败 - 网络错误
但是,我使用了建议的Nodejs -Axios。它因“失败 - 网络错误”而失败。
const downloadSearchResult = async (params) => {
console.log("download")
const link = document.createElement("a");
var axios = require('axios');
var config = {
method: 'get',
url: `https://xxxxxxx.amazonaws.com/v1/xxx?file=${params.row.Filename}`,
headers: {
}
};
axios(config)
.then(function (response) {
link.href = `data:application/pdf;base64,` + response.data;
link.download = params.row.Filename;
link.click();
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
}
chrome显示了json.stringify(wendesp.data),但文件无法保存。
< < < a href =“ https://i.sstatic.net/m583w.jpg” rel =“ nofollow noreferrer”>报道的chrome失败 - 网络错误
I can download a pdf from S3 via Lambda and API Gateway successfully.
However, I used suggested NodeJs - Axios. It failed with "Failed - Network error".
const downloadSearchResult = async (params) => {
console.log("download")
const link = document.createElement("a");
var axios = require('axios');
var config = {
method: 'get',
url: `https://xxxxxxx.amazonaws.com/v1/xxx?file=${params.row.Filename}`,
headers: {
}
};
axios(config)
.then(function (response) {
link.href = `data:application/pdf;base64,` + response.data;
link.download = params.row.Filename;
link.click();
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
}
Chrome showed the JSON.stringify(response.data) but the file won't save.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论