Skip to content

Commit

Permalink
fix: axios-retry usage
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Oct 30, 2023
1 parent 3059e0c commit ade96bc
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/services/swap/oneInch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ export default class OneInch extends BaseSwapper implements ISwapper {
throw new Error("1inch API key not provided");
}
const baseURL = `https://api.1inch.dev/swap/v5.2/${CHAINS[network]}`;
this.apiClient = axiosRetry(
axios.create({
baseURL,
headers: {
Authorization: `Bearer ${config.oneInchApiKey}`,
accept: "application/json",
},
}),
{
retries: 5,
retryCondition: e => e.response?.status === 429,
retryDelay: axiosRetry.exponentialDelay,
this.apiClient = axios.create({
baseURL,
headers: {
Authorization: `Bearer ${config.oneInchApiKey}`,
accept: "application/json",
},
) as any as AxiosInstance;
});
axiosRetry(this.apiClient, {
retries: 5,
retryCondition: e => e.response?.status === 429,
retryDelay: axiosRetry.exponentialDelay,
});
this.log.debug(`API URL: ${baseURL}`);
}

Expand Down

0 comments on commit ade96bc

Please sign in to comment.