【发布时间】:2019-11-08 05:48:55
【问题描述】:
我有一个 python 烧瓶服务器正在运行并且它的 api 被暴露。它用于将 json 转换为 excel 文件。我需要通过节点代码将 json 传递给该 api 并取回响应,该响应将是一个 blob 并在本地保存为 excel 文件。我的第一步是在控制台中显示 blob 对象,但我在控制台中获得了大量无关紧要的数据。这是我的nodejs代码
const request = require('request');
jsonobj={...} //a big json not displaying here
request(
{
method:'post',
url:'http://127.0.0.1:8095/excel/download',
form: jsonobj,
headers: {
"content-type": "application/json"
},
json: true,
}, function (error, response, body) {
//Print the Response
console.log(body);
});
body显示大量数据,我只需要显示excel blob
【问题讨论】:
-
你能发布这个console.log(body)的结果吗;
-
等一下,我会在问题中编辑它。
-
然后试试console.log(body.data);
-
我在 console.log(body.data) 中未定义
-
当我执行 console.log(response.statusCode) 我得到 500
标签: node.js rest post blob filesaver.js