Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit f2a412d

Browse files
committed
promise all for concurrent gas api reqs
1 parent 09150f4 commit f2a412d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ts/utils/backend_client.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ export const backendClient = {
3535
// Median gas prices across 0x api gas oracles
3636
// Defaulting to average/standard gas. Using eth gas station for time estimates
3737
const gasApiPath = 'source/median?output=eth_gas_station';
38-
const gasInfo: WebsiteBackendGasInfo = await fetchUtils.requestAsync(ZEROEX_GAS_API, gasApiPath);
39-
const gasWaitTimes: WebsiteBackendGasWaitTimeInfo = await fetchUtils.requestAsync(
40-
utils.getBackendBaseUrl(),
41-
ETH_GAS_STATION_ENDPOINT,
42-
);
38+
const gasInfoReq = fetchUtils.requestAsync(ZEROEX_GAS_API, gasApiPath);
39+
const gasWaitTimesReq = fetchUtils.requestAsync(utils.getBackendBaseUrl(), ETH_GAS_STATION_ENDPOINT);
40+
41+
const res: [WebsiteBackendGasInfo, WebsiteBackendGasWaitTimeInfo] = await Promise.all([
42+
gasInfoReq,
43+
gasWaitTimesReq,
44+
]);
45+
const gasInfo = res[0];
46+
const gasWaitTimes = res[1];
4347

4448
// Eth Gas Station result is gwei * 10
4549
const gasPriceInGwei = new BigNumber(gasInfo.average / 10);

0 commit comments

Comments
 (0)