【发布时间】:2021-08-26 07:48:28
【问题描述】:
我通过发出以下http请求获得了数据,目前我正在做console.log(),但是如何在邮递员中查看数据。
function getProducts() {
http
.get(url, (res) => {
let body = "";
res.on("data", (chunk) => {
body += chunk;
});
res.on("end", () => {
try {
let json = JSON.parse(body);
console.log(json);
} catch (error) {
console.error(error.message);
}
});
})
.on("error", (error) => {
console.error(error.message);
});
}
【问题讨论】: