【发布时间】:2022-02-17 22:05:31
【问题描述】:
这里是新手!我正在尝试使用其公开的 REST API 和 node.js 对 Binance 加密交换进行基本 ping。我打算在https://github.com/binance-exchange/binance-api-node 中使用一个包装器包,而不是从0 开始编码所有内容,以方便交互。我已经从 github 下载了 binance-api-node 代码到我的 node.js 项目中。
安装包后,尝试运行包含的基本入门代码从服务器获取时间时:
import Binance from 'binance-api-node';
const client = Binance();
client.time().then(time => console.log(time));
我收到此错误:
Uncaught TypeError: Binance is not a function
我也试过了:
const client = new Binance();
但我收到另一个错误,说 Binance 不是构造函数。
这是binance-api-node的index.d.ts中的函数声明
declare module 'binance-api-node' {
export default function(options?: {
apiKey?: string
apiSecret?: string
getTime?: () => number | Promise<number>
httpBase?: string
httpFutures?: string
wsBase?: string
wsFutures?: string
proxy?: string
}): Binance
...
我们将不胜感激。
谢谢!
【问题讨论】:
-
你是如何构建你的打字稿的?
标签: javascript node.js typescript node-modules