Switch getPairCandles to async

This commit is contained in:
Matthias 2024-04-28 11:45:55 +02:00
parent 4d4556e59c
commit e87daa38bf

View File

@ -345,14 +345,13 @@ export function createBotSubStore(botId: string, botName: string) {
return Promise.reject(error); return Promise.reject(error);
} }
}, },
getPairCandles(payload: PairCandlePayload) { async getPairCandles(payload: PairCandlePayload) {
if (payload.pair && payload.timeframe) { if (payload.pair && payload.timeframe) {
this.candleDataStatus = LoadingStatus.loading; this.candleDataStatus = LoadingStatus.loading;
return api try {
.get('/pair_candles', { const result = await api.get('/pair_candles', {
params: { ...payload }, params: { ...payload },
}) });
.then((result) => {
this.candleData = { this.candleData = {
...this.candleData, ...this.candleData,
[`${payload.pair}__${payload.timeframe}`]: { [`${payload.pair}__${payload.timeframe}`]: {
@ -362,11 +361,10 @@ export function createBotSubStore(botId: string, botName: string) {
}, },
}; };
this.candleDataStatus = LoadingStatus.success; this.candleDataStatus = LoadingStatus.success;
}) } catch (err) {
.catch((err) => {
console.error(err); console.error(err);
this.candleDataStatus = LoadingStatus.error; this.candleDataStatus = LoadingStatus.error;
}); }
} }
// Error branchs // Error branchs
const error = 'pair or timeframe not specified'; const error = 'pair or timeframe not specified';