Исправил баг. Ранее если не было валюты в бд, но все равно выдавало график. Исправлено

This commit is contained in:
Данил 2024-08-12 16:33:34 +03:00
parent 2880f2b4c1
commit 5bbb422495

View file

@ -21,7 +21,7 @@ async function gen_chart(from_currency, conv_currency, start_date, end_date) {
end_date
]);
if (!data) return new Error('Missing data');
if (!data['rows'][0]) return 'Missing data';
const date = [];
const rate = [];
@ -54,7 +54,6 @@ async function gen_chart(from_currency, conv_currency, start_date, end_date) {
labels: date,
datasets: [
{
label: 'rate',
borderColor: rate[0] < rate[rate.length-1] ? 'rgb(24, 218, 39)' : 'rgb(243, 85, 50)',
backgroundColor: rate[0] < rate[rate.length-1] ? 'rgb(36, 175, 47)' : 'rgb(218, 56, 24)',
data: rate,