【发布时间】:2022-12-11 17:31:08
【问题描述】:
Installation of the api on gitHub;
const WebSocket = require("ws");
const DerivAPI = require("@deriv/deriv-api/dist/DerivAPI");
// app_id 1089 is for testing, create your own app_id and use it here.
// go to api.deriv.com to register your own app.
const connection = new WebSocket(
"wss://ws.binaryws.com/websockets/v3?app_id=1089"
);
const api = new DerivAPI({ connection });
const basic = api.basic;
basic.ping().then(console.log);
但我得到 ReferenceError: require is not defined
【问题讨论】:
-
您正在从 Node 上的 CommonJS 模块中进行尝试,对吗?
标签: javascript api npm websocket