Closed oDYRASH closed 1 year ago
I don't see the actual error there so I can't help with that but you should always add a .catch( error => console.log( error.message ))
after a .then(...)
Promise.then(...).catch(...)
Then you'll see the error message and be able to debug it easier.
Hello,
As @Your-Name-Here said, an unhandled promise rejection happens when you're missing a catch handler.
Also, if you're looking to use bybit's spot apis, I really recommend using SpotClientV3 instead of SpotClient. It uses their newer V3 APIs (you should consider the SpotClient
with the v1 APIs deprecated).
This also applies for the websocket client, where you should use the spotv3 market instead of spot. Example here: https://github.com/tiagosiebler/bybit-api/blob/master/examples/ws-public.ts#L19
Thank for your help, I find a solution !
Hello there,
I'm facing this error while runing this code :
const { SpotClient } = require('bybit-api'); const ByBitSpotClient = new SpotClient();
ByBitSpotClient.getCandles({ symbol: 'BTCUSDT'}).then(res => console.log('Nb 5minutes candles :',res.result.length))
//////////////////////////ERROR///////////////////////////////// node:internal/process/promises:279 triggerUncaughtException(err, true / fromPromise /); ^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#