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