Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/domains/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export async function login(ctx: ClientContext): Promise<void> {
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" },
},
Expand Down
5 changes: 3 additions & 2 deletions src/utils/retry.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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<AxiosResponse> {
for (let attempt = 1; attempt <= retries; attempt++) {
try {
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));
}
Expand Down
Loading