【发布时间】:2023-04-03 11:31:01
【问题描述】:
对于一个基本问题,我很抱歉,我一直在尝试使用 API 中的 node-fetch 仅提取价格
const fetch = require('node-fetch');
fetch('https://api.binance.us/api/v3/avgPrice?symbol=DOGEUSD')
.then(res => res.text())
.then(text => console.log(text))
let AvgPrice = text.map(text => text.price);
我收到的错误是
internal/modules/cjs/loader.js:968
throw err;
^
拜托,任何建议都非常感谢
【问题讨论】:
-
这与代码本身无关,而与设置无关。你是如何运行这段代码的?
-
我在节点上运行它。问题仅在这一部分(让 AvgPrice = text.map(text => text.price); 我不确定如何使用 map 仅从输出 {"mins":5,"price": "0.5033"}
-
是的,我的意思是,您使用的是 package.json 然后 npm run ... 还是只是 node index.js 或?例如:stackoverflow.com/questions/53545800/…
标签: javascript node.js map-function node-fetch