app.get("/", function (req, res) {
async function showData() {
const res = await fetch("api.openweathermap.org/data/2.5/weather?q=Berlin&appid={apiID}");
const data = await res.json();
console.log(data);
}
})
///当我运行节点app.js时,这应该将数据记录在终端中,但出现错误。
答案 0 :(得分:0)
Fetch返回响应流。 检出answer to this question。使用request-promise / request模块或处理fetch返回的流。