diff --git a/src/domains/session/session.ts b/src/domains/session/session.ts index 403bb9b..4ca7499 100644 --- a/src/domains/session/session.ts +++ b/src/domains/session/session.ts @@ -66,7 +66,14 @@ export async function login(ctx: ClientContext): Promise { data: { username: ctx.config.username, password: ctx.config.password, - domain: ctx.config.broker, + + // TODO:: take a look at this below, domain nor vendor seems required. it works if i comment out both. + // however i still use it since i see brokers use it as well in the login endpoint. + + // domain: ctx.config.broker, + vendor: ctx.config.broker, + + // END TODO:: }, headers: { "Content-Type": "application/json" }, }, diff --git a/src/utils/retry.ts b/src/utils/retry.ts index f6911c9..88dd941 100644 --- a/src/utils/retry.ts +++ b/src/utils/retry.ts @@ -1,4 +1,4 @@ -import axios, { type AxiosRequestConfig, type AxiosResponse } from "axios"; +import axios, { type AxiosRequestConfig, type AxiosResponse, isAxiosError } from "axios"; export async function retryRequest(config: AxiosRequestConfig, retries = 3): Promise { for (let attempt = 1; attempt <= retries; attempt++) { @@ -6,7 +6,8 @@ export async function retryRequest(config: AxiosRequestConfig, retries = 3): Pro return await axios(config); } catch (error: unknown) { const message = error instanceof Error ? error.message : "Unknown error"; - console.warn(`[dxtrade-api] Attempt ${attempt} failed: ${message}`); + console.warn(`[dxtrade-api] Attempt ${attempt} failed: ${message}`, config.url); + if (isAxiosError(error) && error.response?.status === 429) throw error; if (attempt === retries) throw error; await new Promise((res) => setTimeout(res, 1000 * attempt)); }